Back
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.
You can use the below-mentioned code to add new key to a dictionary:-
d = {'key':'value'} print(d) d['mynewkey']='mynewvalue'print(d)
d = {'key':'value'}
print(d)
d['mynewkey']='mynewvalue'
31k questions
32.8k answers
501 comments
693 users