0 votes
1 view
in Python by (30.9k points)
edited by

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.

1 Answer

0 votes
by (73.5k points)

You can use the below-mentioned code to add new key to a dictionary:-

d = {'key':'value'} 

print(d) 

d['mynewkey']='mynewvalue'

print(d)

...