Currently I am writing some validation code for an input in my program and I cannot seem to get the error message to display correctly!
I have my types defined in a string list like this:
types = ['Guitar','Piano','Drums','Violin','Voice','Flute','Cello','Bass'] Then my code for the validation check is:
typevalid = False while typevalid == False: Type = input("Please enter the tutor type: ").title() for count in range (0,7): if Type == types[count]: typevalid = True Tutor = (Name,Type) insert_data(Tutor) print("New data added") print() if Type != types[count]: print("!!Please enter a correct type!!\n") add = input("Do you wish to add another record? (y/n) ") I have tried changing and moving the second if Type code and it either repeats the error X amount of times becuase of the range loop or it will display the error message twice.
Any suggestions on how I can get this to work?