I just started learning python +-36 hours. I'm new to this whole coding/programming thing. I'm trying to build a simple program for my exercise, basically my program will asks "Are you willing to take the question?", if I input 'Yes', I'm hoping the program to asks "What is the value of Phi?", and if I input "No", I'm hoping the program will print "Have a good day", my problem is, if I input "No" the program will still asks "What is the value of Phi?". How do I fix this?. TIA.my codes
1 Answer
Reason is that you ask the question about phi value before if statement and use it as a parameter for input function.
Also, it will be better if you use else or elif to avoid extra calculations. Your code should be more like:
name = input('Input your name ')
terms = input('Are you willing to take this questions ')
if terms == 'Yes':
# Ask question about phi value here
elif terms == 'No':
# Wish gl
else:
# Tell them that answer should be Yes/No