I am trying to use the While loop to validate a user response. I want user to enter "Y" or "N" to continue and kepe asking until a valid response is sought using while loop. I aks for user response within block and I am not using break as i am thinking having a valid response shoud break out of loop automatically. Despite receiving valid user response, the while loop keeps going. Below is my code
enter code here
fruit_list = ["apple", "banana", "cherry", "gooseberry", "kumquat", "orange", "pineapple"]
find = "Y"
while find == "Y":
fruit_found = False
print(fruit_list)
fruit = input("Enter the fruit you want to find in the list above: ").lower()
n=0
for i in fruit_list:
if fruit == fruit_list[n] and fruit_found==False:
print("the fruit you are searching is on position", n+1, "in the fruit list")
fruit_found = True
else:
n+=1
if fruit_found == False:
print("the fruit you are searching is not in the list")
find = input("Do you want to find another fruit? Enter Y for Yes and N for No: ").upper()
#work in progress to validate the response to continue. Y or N
**while find != "Y" or "N" :
print("Entered response is not valid. ")
find = input("Test Do you want to find another fruit? Enter Y for Yes and N for No: ").upper()**
print("Thank you")