Loading...
Loading...
Loading...
Two words are anagrams when they use exactly the same letters the same number of times, in any order.
Read two lowercase words and print Anagrams or Not anagrams. Solve it by counting the letters of each word with a dictionary.
Anagrams or Not anagrams.Example 1
Input
listen silent
Output
Anagrams
Same letters, different order.
Example 2
Input
rat car
Output
Not anagrams
Different letters.
Try the problem first. Open one hint at a time.
Count the letters of each word into its own dictionary.
Two dictionaries compare equal with == when they have the same keys and the same counts. A small function avoids writing the loop twice.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor