0

I would like the program to ask the user for the password if the password wasnt correct. How do I do it?

#program that saves user passwords

user_input = ""

FB = input("what is your facebook pasword \n")
print("your facebook passoerd is " + FB  + " is this correct?")

user_input = input()
if (user_input == "yes"): 
    print("password has been saved")
elif user_input == "no":
    print("password was not saved")
else:
    print("i do not understand. sorry")

1 Answers1

0

Welcome to StackOverflow!

One of the usual tricks is to wrap all of that in a while loop and break the loop if user input is anything other than "no"

while True:
    user_input = ""

    FB = input("what is your facebook pasword \n")
    print("your facebook password is " + FB  + " is this correct?")

    user_input = input()
    if user_input is "yes": 
        print("password has been saved")
        break #add break here to exit the program
    elif user_input is "no":
        print("password was not saved")
    else:
        print("i do not understand. sorry")
        break #add break here to exit the program
gavin
  • 793
  • 1
  • 7
  • 19
Andreas
  • 2,455
  • 10
  • 21
  • 24
  • Whether I say yes or no the only thing it does it say I do not understand. What am I doing wrong? –  Nov 12 '18 at 04:55