1

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

supercut_
  • 13
  • 2
  • Here is a very good answer: https://stackoverflow.com/questions/2395160/what-is-the-correct-syntax-for-else-if – Ferrariic Jul 22 '22 at 06:23

1 Answers1

0

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
Zorojuro
  • 71
  • 5