- Joined
- Apr 26, 2021
- Messages
- 1
- Reaction score
- 0
I am trying to write a code which takes two variables named stock and ingredients and returns the missing ingredients.
The stock part is a dictionary in pairs : ("tomato", 6)
This function will check if I have enough of every ingredient and if there isn't that item at all in the stock or just missing partially, the function will return the list of those items. If there isn't a missing one, it will return an empty list.
stock = {"apple":10, "potato":7, "banana":6, "cherry":10}
ingredients = [("banana",10), ("potato", 8), ("apple",5)]
checkStock(stock, ingredient) will return:
[("potato",1), ("banana",4)]
I am using def checkStock(stock, ingredient): but I cannot find a way of extracting the missing ingredients out of the stock. How can I do it?
The stock part is a dictionary in pairs : ("tomato", 6)
This function will check if I have enough of every ingredient and if there isn't that item at all in the stock or just missing partially, the function will return the list of those items. If there isn't a missing one, it will return an empty list.
stock = {"apple":10, "potato":7, "banana":6, "cherry":10}
ingredients = [("banana",10), ("potato", 8), ("apple",5)]
checkStock(stock, ingredient) will return:
[("potato",1), ("banana",4)]
I am using def checkStock(stock, ingredient): but I cannot find a way of extracting the missing ingredients out of the stock. How can I do it?