Created
March 28, 2017 17:55
-
-
Save 3h5a9/c9f71df4c08b1eabf262a3ef76d4d95e to your computer and use it in GitHub Desktop.
loop is not ending
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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