Python 3.7 I want to request first and last name from user and if they input numbers as input, the code informs them of the error and then, returns to requesting code to get user's name again. I can code the input statements and the validation, but if the user enters the wrong data, how to get the code to go back to requesting the input response again.
I have tried a function (but python prohibits using function variables out of the function).
while userinput == "n":
fname = input("Please enter your first name: ")
lname = input("Please enter your last name: ")
print("first name:", fname,
"last name:", lname)
userinput = input("Is this information correct? y or n: ")
print(fname, lname)
I want to solicit user input, validate it and if errant, prompt user for the same input again until it is validated and then move on to the next input request.