Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
The correct answer is paris, but the player types PaRiS with spaces and capital letters. Why is the reply marked wrong, and how do you fix it?
lower() and strip() make a reply easier to compare.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
Why. " PaRiS " == "paris" is False. Python compares the exact characters. The capital letters and the spaces make a different text.
Fix. Clean the reply before comparing: reply.lower().strip() makes the letters small and removes the spaces at the two ends. Then the comparison is True.
Log in to join the discussion.
Loading…