Hi, i'm wanting to update the stock list at the end so that the fruit that's given is taken subtracted from the original stock list. The code i've written isn't updating it it's just staying the same. Any idea what i can do to fix this?
import json stock_json= json.load(open("stock.json")) queue_json= json.load(open("queue.json")) queue=[ ["James Bruce", "Bananas"], ["Katherine Newton", "Bananas"], ["Deborah Garcia", "Pears"], ["Marguerite Kozlowski", "Pineapples"], ["Kenneth Fitzgerald", "Pineapples"], ["Ronald Crawford", "Bananas"], ["Donald Haar", "Apples"], ["Al Whittenberg", "Bananas"], ["Max Bergevin", "Bananas"], ["Carlos Doby", "Pears"], ["Barry Hayes", "Pineapples"], ["Donald Haar", "Bananas"] ] stock={ "Apples": 14, "Bananas": 14, "Pineapples": 0, "Pears": 8 } for i in queue: if stock[i[1]]>0: print("Gave {} to {}".format(i[1],i[0])) else: print("Could not give {} to {}".format(i[1],i[0])) def total_stock(fruit): total=0 for i in fruit: if stock[i]>0: stock[i]=stock[i]-1 return total print stock _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor