So I want to count up all the values together to make a totalItems var which will be printed underneath the list. the output gives me 5 instead of it all being counter up. Can someone explain me why, not just give the right code.
stuff = {'coins': 5, 'arrows': 42, 'rope': 1}
def getInvent(inventory):
itemTotal = 0
print('Inventory:')
print(str(stuff['coins']) + ' Coins')
print(str(stuff['arrows']) + ' Arrows')
print(str(stuff['rope']) + ' Rope')
for k, v in stuff.items():
itemTotal = itemTotal + v
print('Total number of items: ' + str(itemTotal))
return itemTotal
getInvent(stuff)