def isAnagram(A,B): if sorted(A) == sorted(B): print("Yes") else: print("No") isAnagram("earth","heart") #Output: Yes #Hope this helps:)