Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (47.6k 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 (106k 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
0 votes
1 answer
0 votes
1 answer
asked Sep 17, 2019 in Python by Sammy (47.6k points)
0 votes
4 answers

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...