Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Verify Anagrams by kamilinho20
def verify_anagrams(first_word, second_word):
listword = list(first_word.lower())
print (listword)
for letter in second_word:
if len(listword) == 0:
return False
try:
listword.pop(listword.index(letter.lower()))
except ValueError:
if first_word.lower().find(letter.lower()) == -1:
continue
else:
break
print(listword, letter)
while 1 > 0:
try:
listword.pop(listword.index(' '))
except ValueError:
break
if len(listword) == 0:
return True
return False
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert verify_anagrams(" Hi all ", "all hi") == True
assert verify_anagrams("Programming", "Gram Ring Mop") == True, "Gram of code"
assert verify_anagrams("Hello", "Ole Oh") == False, "Hello! Ole Oh!"
assert verify_anagrams("Kyoto", "Tokyo") == True, "The global warming crisis of 3002"
Dec. 21, 2016