add a title
hey my "else:" command isn't working. Idk why. I'm trying to make it so if someone is typing their name they say "yes" or "no" if they are satisfied with it. but if they type something else then I but "else:[new line] gameover = True" if anyone knows how to fix this. Just to clarify the language is Python
edit: will people please stop replying i got the answer, thanks. (sorry if this sounded a bit mean)
@DiegoCamacho3 The answer I get to your question is this:
game = True if (answer == "yes"): print("very nice to meet you,",name) elif (answer == "no"): name = str(input("what is your name?")) else: game = False print ("Goodbye!") if (game == True): # Your rest of the statements pass
If this is not the answer then please elaborate your question!
The else statement does work. If i don't type in anything like a yes or no, it just says please just answer yes. But if you are saying you want an input when they say something else try this:
if answer == "yes": print("nice to meet you,",name) elif answer == "no": name = str(input("what is your name?")) else: game = False print ("please just answer yes") answer = str(input("are you satisfied with your name? type: yes or no please: "))
And so on. put your code in. But you might want to use a while loop -
while answer != yes:, and the code should repeat.
That should work