-2

let me start off by saying, that i am a BEGINNER to coding. i use python 3.4.GUI.

so i've got this code:

register = input("have you registered an 
account?")
if register == "yes":
    print("you may proceed to log in")
if register == "no":
    print("please, create an account")
else:
    print("that is not a valid answer")

how to i create a while true loop on this so that if the user enters anything other than "yes" or "no", they get taken back to the start? thanks!

xxMagnum
  • 21
  • 1
  • 8

1 Answers1

1

Uncomment break if you want to end the loop after correct input.

while True:
    register = input("have you registered an account?")
    if register == "yes":
        print("you may proceed to log in")
        # break?
    elif register == "no":
        print("please, create an account")
        # break?
    else:
        print("that is not a valid answer")
Amadej Kastelic
  • 577
  • 5
  • 9