1
Suppose I have the following dictionary:
dicionario = {'exemplo1':1, 'exemplo2':2, 'exemplo3':3}
How do I add a key-value without changing the ones already added? In case I want it to stay that way:
#Como eu quero
dicionario = {'exemplo1':1, 'exemplo2':2, 'exemplo3':3, 'exemplo1':100}
I’ve tried it a few ways here, but I can only get it to update the value of the key that has already been added.. That’s how it works.:
#Como fica:
dicionario = {'exemplo1':100, 'exemplo2':2, 'exemplo3':3}
Adriano, it is important you know that every key inside a dictionary is unique... IE, you can not have two keys
exemplo1
... If you assign a value to an existing key you will overwrite it.– fernandosavio