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 - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -