Check whether two strings are anagram of each other in Python | Python tutorils

Опубликовано: 30 Сентябрь 2024
на канале: Code With Cougar
29
0

'''An anagram of a string is another string that contains the same characters,
only the order of characters can be different.
For example, “abcd” and “dabc”, silent and listen, triangle and integral are an anagram of each other.'''


def isAnagram(str1, str2):
return sorted(str1) == sorted(str2)

print(isAnagram("silentr", "lirsten"))
#CodeWithCougar
Please Subscribe to Code With Cougar:
   / @code-with-cougar