Created
February 17, 2019 01:25
-
-
Save Ventsislav-Yordanov/dc465d7085cc30faa81dd8b477692a07 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
""" | |
if type(word1) != str or type(word2) != str: | |
raise TypeError("The word1 and word2 must be strings") | |
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