Sunday, 11 August 2013

Python - Is it possible to add on to a value (int) already defined in a key for a dictionary?

Python - Is it possible to add on to a value (int) already defined in a
key for a dictionary?

I'm trying to add a single value (+50 to gold) to key in an already
populated dictionary. Is it possible to do so without changing all the
values in the dictionary?
inventory = {'gold' : 500,
'pouch' : ['flint', 'twine', 'gemstone']
I saw that I can modify all the values in a dictionary but have found
nothing for modifying just one. Was just wondering if that was possible.

No comments:

Post a Comment