0

I am trying to get my function to loop back and ask a question again if the user inputs no when asked. Instead of going to my elif statement, it defaults to the first if statement no matter what I put.

def full_name(): # catagorize if user wants to input full name
    try:
        
        while True:
            
            f, n = input("What is the full name? ").split()
            user_confirm = input(f.upper() + " " + n.upper() + ". " + "That's correct? ")

            if user_confirm.lower() == str("yes") or str("y"):
                print("User confirm")
                break

            elif user_confirm.lower() == str("no") or str("n"):
                print("User deny")
                continue
        
    except Exception: print("full name error")
        #pass
    pass
khelwood
  • 55,782
  • 14
  • 81
  • 108
phynix
  • 29
  • 5
  • Does it need to be `while True:`? Can't you make a bool like `isConfirmed = False` and put `while not isConfirmed:`? – ThePikachuIH Nov 04 '20 at 18:17
  • I apologize for my ignorance but what would that do? Isn't not False the same as True or am I committing a rookie mistake? – phynix Nov 04 '20 at 18:22
  • If you have `isConfirmed = False` and have your `while` loop as `while not isConfirmed`, then if you say `isConfirmed = True` in your first `if` statement, and it will break out of the loop. It seemed to work for me in a repl. – ThePikachuIH Nov 04 '20 at 18:33
  • 1
    Hmm alright, I'm going to give this a go on my break and report back. Thank you! – phynix Nov 04 '20 at 19:12

0 Answers0