Is it possible to add a key to a Python dictionary after it has been created? It doesn t seem to have an .add() method.
Add key to a dictionary in Python
De openkb
Sommaire |
Questions
Answers
>>> d = { key : value } >>> print d { key : value } >>> d[ mynewkey ] = mynewvalue >>> print d { mynewkey : mynewvalue , key : value }
Source
License : cc by-sa 3.0
http://stackoverflow.com/questions/1024847/add-key-to-a-dictionary-in-python