On 04/30/2018 04:15 PM, Shannon Evans via Tutor wrote: > 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? >
so a few notes in addition to what Alan has already written. COnsider: if stock[i[1]]>0: # if it reads awkwardly, look for a better way to write it. # how quickly would you know what stock[i[1]] is if you looked # at it a week later? # instead consider - what is an "i" here? It's a list, # with a typical entry being # ["Ronald Crawford", "Bananas"] # Why not unpack that into named variables right in the loop? for (person, fruit) in queue: # now you can refer to things by useful names: if stock[fruit]>0: print("Gave {} to {}".format(person,fruit)) # Hint: this is the ideal place to decrement the stock count does that help? _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor