I am new to Python and have to write this code for a school project.
When the user says "No", meaning they are not US-based, I want the program to exit. When the user doesn't type in anything I would like it to say "please type y or n" and to keep displaying this message until they respond correctly.
while location == "":
location = input("Are you based in the US? Y/N ")
if location.upper().strip() == "Y" or location.upper().strip() == "YES":
print("Great to know you're based here in the states")
elif location.upper().strip() == "N" or location.upper().strip() == "NO": #when input is N or No display not eligible
print("Sorry to be our supplier you must be based in the US!")
quit() #stops program
else:
location = "" #if NZ based variable is not Y or N set NZ based variable to nothing
print("Type Y or N") #displays to user To type Y or N