Ask coding questions

← Back to all posts
I Have A Problem
REGoG (0)

In this program/game there is an issue where you may have to input something twice.

Please don't steal it.

Reply in the comments section.

REGoG (0)
MrVoo (102)

It's doing this because you have input() in your if statements, and Python thinks your trying to check every input. Instead, do it like this:

answer = input()
if answer == 'bonk':
  print('You said bonk!')
Coder100 (18930)

input takes the user input and returns it.
And will do this every time, so to have it say No, python will have to do the input function twice: one for yes and one for no.

So you want to store the input into a variable, like this:

begin = input()
if begin == "Yes":
elif begin == "No":
ch1ck3n (2388)

where in the program