I have this loop and I am having difficulty making it to accept online integer. No string.
def addItem(menu, order):
# get item no from user
itemNo = int(input('your choice : '))
# validate item no
if itemNo == -1:
return itemNo
while itemNo not in range(1, len(menu) + 1):
itemNo = int(input('Invalid input, try again: '))
if itemNo == -1:
return itemNo
Aucun commentaire:
Enregistrer un commentaire