Skip to content

Instantly share code, notes, and snippets.

@chelseadole
Created October 27, 2017 18:21
Show Gist options
  • Save chelseadole/bf56137106932e83a595146943e8ab2a to your computer and use it in GitHub Desktop.
Save chelseadole/bf56137106932e83a595146943e8ab2a to your computer and use it in GitHub Desktop.
Tests if two words are anagrams
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