Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
newbie solution in Clear category for Verify Anagrams by ewa_c
def verify_anagrams(first_word, second_word):
allLetters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
first_word = first_word.lower()
second_word = second_word.lower()
exit = 1
for x in allLetters:
numberFirst = 0
numberSecond = 0
for i in range(len(first_word)):
if x == first_word[i]:
numberFirst += 1
for i in range(len(second_word)):
if x == second_word[i]:
numberSecond += 1
if numberFirst != numberSecond:
exit = 0
return exit==1
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert isinstance(verify_anagrams("a", 'z'), bool), "Boolean!"
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"
Nov. 1, 2016