我编写了检查两个字符串是否是Python中彼此字符串的逻辑。有人可以检查这是否正确或是否有更好的出路:
def checkanagram(str1,str2):
l1 = list(str1)
l2 = list(str2)
temp = str1
for c in temp:
if c in l2:
l1.remove(c)
l2.remove(c)
if len(l1) == 0 and len(l2) == 0:
return True
else:
return False
str1 = input()
str2 = input()
if checkanagram(str1,str2):
print ("It is an anagram")
else:
print ("Its not an anagrams")