Created
October 27, 2017 18:21
-
-
Save chelseadole/bf56137106932e83a595146943e8ab2a to your computer and use it in GitHub Desktop.
Tests if two words are anagrams
This file contains 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 anagram(word1, word2): | |
"""Check if word1 and word2 are anagrams.""" | |
listed_w1, listed_w2 = list(word1), list(word2) | |
sorted_w1, sorted_w2 = listed_w1.sort(), listed_w2.sort() | |
if listed_w1 == listed_w2: | |
return True | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment