I want to design a 'survey' inspired by a flow chart and I can't understand why it's not working. I want something simple without packages since I haven't wrapped my head around them yet.
How it should work:
Q1 - input is yes -> Q2 - input yes - Q3 -> input yes - ... - Q9 - input no -> Q10
Q1 - input is no -> break
Q1 - input maybe -> Q1 AGAIN
When I currently input anything different from yes or no it starts from the beginning (Q1).. can I make it repeat the IF statement in all the questions until input is yes or no??
while True:
x = input ('question_text' )
if x.lower () == 'yes':
x = input ( 'question2_text' )
if x.lower () == 'yes':
x = input ( 'question3_text' )
if x.lower () == 'yes':
ETC...
if x.lower () == 'no':
print ( 'No.' )
break
else:
print ('ONLY YES/NO')
if x.lower () == 'no':
print ( 'No.' )
break
else:
print ('ONLY YES/NO')
if x.lower () == 'no':
print ( 'No.' )
break
else:
print ('ONLY YES/NO')
if
. I would suggest implementing a state machine: a variable holds current state (e.g. list of things user entered so far) and while loop which first checks current state and then asks for one input, which depends on the current state. – zvone Dec 3 at 1:04