Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (47.6k 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 (106k 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

0 votes
1 answer
+1 vote
1 answer
asked May 24, 2019 in Python by Anvi (10.2k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
asked Aug 27, 2019 in Python by Sammy (47.6k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

30.5k questions

32.6k answers

500 comments

108k users

Browse Categories

...