I’m curious about something in the “Stocking Out” exercise. We are instructed to subtract from the stock after we add the price to “Total”. We’ve already checked for available stock at this point, so I’m wondering what the reason we should change the dictionary after adding to the variable is. I imagine it has something to do with how code should be structured that I have yet to learn? It seems to function correctly if I do it the opposite way ( except the first time I tried it said my “total” line was indented improperly, worked fine after that).
I just want to know if there’s something more to this that would be good to know in the future. Thanks for the help!
EDIT: So I just thought about it after posting and realized you wouldn’t want to subtract from the dictionary (or change it), before using the values in it to add to the variable “total”. Essentially you shouldn’t change a value you need to use before using it.
Am I correct about this? Or am I still missing something? Thanks again!!
total += prices[item] stock[item] -= 1 or stock[item] -= 1 total += prices[item]