So im supposed to show all three items and their amount, but what im not understanding is that when i do print(inventory[item]) it shows 3, 5 and 1 in the Output, but in the solution it says var amount = inventory[item] and display_item(item, amount) so now amount is the numbers? and item is the string? I'm quite confused so if anybody could make it a little easier to understand that would be appriciated
#Please help me understand this dictionary
5 messages · Page 1 of 1 (latest)
display_item is custom function that is hidden you can see the definition on the left side
for item in inventory loops through all the items(the string name)
so when you do display(item) it takes the "key"
inventory[item]
this will return the "value" of the specific key
inventory["healing_heart"] will return the value of 3
so in generic terms
for key in dictionary:
var value = dictionary[key]
display_key(key, value)
ohhh i think i get it then. So if i do var amount = Inventory[item] that takes the key from item so now amount is the key AKA the number. so the item becomes the string then. If im understanding correctly