All I'm trying to get is for the input list_
to only be 0-10
and when it is not, have the user input it again until they do. So if they enter 'spacebar', 'p', '[' or anything along those lines it should only be valid for 0-10. This is all I could come up with:
list1 = ["bacon", "cheese", "cheddar", "milk", "apples", "lamp", "door", "blanket", "rug", "windows", "coat"]
list_ = input("What item do you want? (0-10) ")
while True:
if (list_ != "0") and (list_ != "1") and (list_ != "2") and (list_ != "3") and (list_ != "4") and (list_ != "5"):
list_ = input("What do you want from the list? (0-10)")
if (list_ != "6") and (list_ != "7") and (list_ != "8") and (list_ != "9") and (list_ != "10"):
list_ = input("What do you want from the list? (0-10)")
elif list_ == "0":
print(list1[0])
break
elif list_ == "1":
print(list1[1])
break
elif list_ == "2":
print(list1[2])
break
elif list_ == "3":
print(list1[3])
break
elif list_ == "4":
print(list1[4])
break
elif list_ == "5":
print(list1[5])
break
elif list_ == "6":
print(list1[6])
break
elif list_ == "7":
print(list1[7])
break
elif list_ == "8":
print(list1[8])
break
elif list_ == "9":
print(list1[9])
break
elif list_ == "10":
print(list1[10])
break