How can I check if a string has the same characters? Python -


i need able discern if string of arbitrary length, greater 1 (and lowercase), has same set of characters within base or template string.

for example, take string "aabc": "azbc" , "aaabc" false while "acba" true.

is there fast way in python without keeping track of permutations of first string , comparing test string?

sort 2 strings , compare them:

sorted(str1) == sorted(str2) 

if strings might not same length, might want make sure of first save time:

len(str1) == len(str2) , sorted(str1) == sorted(str2) 

Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -