What my goal is: I am currently trying to build a simple troubleshooting program. the variable, current_question is meant to update as the value of each input/question along a nested if statement. This is so the code can identify which question it is currently asking. As a result, I can loop back to the current question in case the user enters the wrong data (not yes and not no)
The issue However, when I test the code and it continues to the second question, this variable is not updated to questions 2,3,4 BUT the loop works only with the first question whenever I type in the wrong data. I have been trying to solve this for a long time but still haven't reached a solution, so I thought this would be a good place to start.
The code!
import time
current_question = ()
i = 1
while i <= 4:
q1 = str(input('Is your phone wet? ')).lower()
current_question = q1
i = i + 1
if q1 == 'yes' or q1 == 'Yes':
print('dry it out')
break
elif q1 == 'no' or q1 == 'No':
q2 = str(input('is your phone cracked? ')).lower()
current_question = q2
i = i + 1
if q2 == 'yes' or q2 == 'Yes':
print('replace screen')
break
elif q2 == 'no' or q2 == 'No':
q3 = str(input('are you able to download apps/videos? ')).lower()
current_question = q3
i = i + 1
if q3 == 'yes' or q3 == 'Yes':
print('delete any apps or videos that you don\'t need')
break
elif q3 == 'no' or q3 == 'No':
q4 = str(input('Is your phone unresponsive? ')).lower()
current_question = q4
i = i + 1
if q4 == 'yes' or q4 == 'Yes':
print('restart it')
break
elif q4 == 'no' or q4 == 'No':
print('contact the supplier')
break
while current_question != 'yes' and current_question != 'no':
print('try again')
time.sleep(1)
print(current_question)