Skip to content

Instantly share code, notes, and snippets.

@Ventsislav-Yordanov
Created February 19, 2019 18:59
Show Gist options
  • Save Ventsislav-Yordanov/7e6b7a52f1dfa4d574ae3b9baac87d2d to your computer and use it in GitHub Desktop.
Save Ventsislav-Yordanov/7e6b7a52f1dfa4d574ae3b9baac87d2d to your computer and use it in GitHub Desktop.
def check_anagrams(word1, word2):
"""
Check if the two passed words are anagrams.
Returns True if the word1 and word2 are anagrams, otherwise returns False
"""
assert type(word1) == str, "The word1 must be a string"
assert type(word2) == str, "The word2 must be a string"
return sorted(word1) == sorted(word2)
print(check_anagrams("silent", "listen"))
print(check_anagrams("silent", 5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment