According to Wikipedia, we have the following definition of an anagram:
An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
For example, listen
and silent
are anagrams.
Implement a function called anagrams
, that takes word1, word2
and returns True
, if those words are anagrams and False
otherwise.
We should take the following into consideration:
- Casing does not matter, meaning
LISTEN
andsilent
are anagrams. - Whitespace does not matter, meaning
New York Times
andmonkeys writting
are anagrams.
Signature
def anagrams(word1, word2):
pass
Examples
anagrams("listen", "silent") is True
anagrams("LISTEN", "silent") is True
anagrams("python", "ruby") is False
anagrams("New York Times", "monkeys write") is True
anagrams("snake", "sssnakee") is False