0 votes
1 view
in Python by (47.7k 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 (107k 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)

Related questions

0 votes
1 answer
asked Sep 17 in Python by Sammy (47.7k points)
+1 vote
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...