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

Question:

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

Asked By: Zzrod

||

Answers:

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
Answered By: Chamesh
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.