I am a GCSE student needing help for my computer science case study. I would like to check if an input is in a list as validation for my code. Here is a small example of what im trying to do.
Days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"] #The array
DayChoice = input("Enter a day") #Asking user to input day
while True:
for i in Days: #Trying to loop through days to see if input matches list
if DayChoice == i:
print("correct input")
break #If yes then end validation
else:
print("enter correct input") #If wrong ask to input again
Try running it, it has some sort of looping error and I assume the while is probably in the wrong places. I want the program to check if the input is in the list and if it is, break from the whole loop, and if it isn't, then it will ask the user to input again. If someone can rewrite/edit the code then it will be appreciated. And please take into consideration that this should be GCSE level.