Read the question, write Python on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read two words (one per line) and print yes if they are anagrams of each other, otherwise no.
Two words are anagrams when they use exactly the same letters, just rearranged. Compare case-insensitively.
Input. Two lines, each one word.
Output. yes or no (lowercase).
Examples
Input
listen silent
Output
yes
Input
hello world
Output
no
Hint
- If you sort the letters of each word, anagrams become identical.
- sorted("listen") == sorted("silent") is True. Lowercase both first.
Show correct code
Peek only after you have tried. You can still Check your own version.
a = input().strip().lower()
b = input().strip().lower()
print("yes" if sorted(a) == sorted(b) else "no")
main.pyPython · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.