Let's write an anagram checker.
Two words are anagrams of each other if the letters of one can be rearranged to fit the other. e.g. dormitory
and dirtyroom
.
Write a program that lets the user enter two strings, and tells them if they are anagrams of each other.
- Convert the strings into lists (
list
) - Sort the letters of each word (
sort
) - Check if the two are equal
>>> enter the first word: dormitory
>>> enter the second word: dirtyroom
>>> 'dormitory' and 'dirtyroom' are anagrams
- Convert each word to lower case (
lower
) - Remove all the spaces from each word by replacing them with empty strings (
replace
)
Make your program ignore punctuation when checking anagrams.
Let the user enter as many words as they choose. If every word is an anagram of every other word, let the user know.