0 votes
1 view
in Python by (47.7k points)

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)
edited by

To add a new keys to a dictionary you can use the below-mentioned code:-

d = {'key':'value'} 

print(d) 

d['mynewkey'] = 'mynewvalue' 

print(d) 

To know more about this you can have a look at the following video tutorial:-

Related questions

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


Categories

...