I would like to be able to validate that the user has entered a valid name within my program. If they have not entered a valid name i want the program to continue to prompt them to enter their name again. If the name entered is valid i would like the program to greet the user.
So far i have:
import re
user_name = input("Please enter your name: ")
if not re.match("^[A-Za-z]*$", user_name):
print ("Error! Make sure you only use letters in your name")
else:
print("Hello "+ user_name)
How would i loop this if their name is not valid??
^[A-Za-z]+$instead of^[A-Za-z]*$.