After getting a bunch of undesired output(s) from my code I realised that I may have no clear understanding of for and while loops. My intention is to "nest" an if block in a while or for loop, where instead of exiting when the user inputs an unxpected answer it simple loops back (not infinitely)until the correct or at least desired input is taken in. Please help and possibly explain. Thank you.
employment_history = str(input("Have you ever been employed? Y/N: " ).title())
if employment_history == "Y":
comp_name = str(input("What was the name of the company you worked for? ").title())
ref_1 = str(input("Who was your reference at "+ comp_name +"? ").title())
ref_1_num = input("What was "+ ref_1 + "'s number? ")
ref_1_number = ref_1_num[0:3]+'-'+ ref_1_num[3:6]+'-'+ ref_1_num[6:10]
print("The company you worked for was "+comp_name+", "+ ref_1 +" was your reference ", "their number was "+ ref_1_number +".")
elif employment_history == "N":
print("No employment record entered.")
while employment_history != "Y" and "N":
print("Please enter Y for 'YES' and N for 'NO'.")
return