Exercise - 36 - Game

This is the game I was starting to code for.

Python Text-Based Game

Here is the problem:
When the prompt appears for how the player wants to respond to the door knock, and I type ‘another’, it runs the second elif statement. I have not been able to figure out why. Whatever I do, it always runs the second elif statement.

"not" is in "another".
:wink:

1 Like

Oh…wow

Is there any way I can make this work like I want it to?

Several.
Since you are checking for whole words, you might want to split the input string. Try this in the REPL:

>>> answer = "another time"
>>> words = answer.split()
>>> words
['another', 'time']
>>> "not" in words
False
2 Likes

Thanks for your help.

1 Like

Nice, even I didn’t notice this.

1 Like
A free service run by Zed A. Shaw for learncodethehardway.org.