Home > Blockchain >  How do I make it so my code can return to a line if the User says No
How do I make it so my code can return to a line if the User says No

Time:09-19

textinfo = str(input("Insert Text here:"))
LocateInText = str(input("Insert What needs to be found (i.e words, numbers, ect):"))
Confrim = str(input("Are you sure? This may take a bit, Y or N:"))

if Confrim == "N":
    find: LocateInText

I am trying to make it so that when the user says N (no) It repeats LocateInText to correct themselves

CodePudding user response:

If the textinfo does not need to be edited you can add the LocateInText and Confirm into a while loop and break it when user confirms it.

textinfo = str(input("Insert Text here:"))
while True:
    LocateInText = str(input("Insert What needs to be found"))
    Confrim = str(input("Are you sure? This may take a bit, Y or N:"))
    if Confirm == 'Y':
        break
# do next thing here
  • Related