programming-examples/python/Misc/Python program to check if a given string is an anagram of another given string.py
2019-11-15 12:59:38 +01:00

10 lines
260 B
Python

def is_anagram(str1, str2):
list_str1 = list(str1)
list_str1.sort()
list_str2 = list(str2)
list_str2.sort()
return (list_str1 == list_str2)
print(is_anagram('anagram','nagaram'))
print(is_anagram('cat','rat'))