Skip to content

Instantly share code, notes, and snippets.

@3h5a9
Created March 28, 2017 18:06
Show Gist options
  • Save 3h5a9/76c4c0470dacd31a5633639b42b01c17 to your computer and use it in GitHub Desktop.
Save 3h5a9/76c4c0470dacd31a5633639b42b01c17 to your computer and use it in GitHub Desktop.
unlimited loop
stock = {'apple': 10, 'banana': 20, 'orange':0 }
alreadyAte = ['ehsan']
food = input('What food was eaten? ')
person = input('Who ate the food? ')
def menu():
print("Press 1: To add stock. ")
print("Press 2: To check stock. ")
print("Press 3: To enter purchase. ")
print("Press q: To quit the program. ")
return input("What would you like to do? ")
run = menu()
while True:
if food in stock:
if person in alreadyAte:
print('{} was sent to the brig'.format(person))
else:
if stock[food] > 0:
stock[food] -= 1
alreadyAte.append(person)
print("{} ate {}".format(person,food))
else:
print('{} did not eat because we are out of {}'.format(person,food))
else:
print('{} is out of stock'.format(food))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment