How to Add an Item to Dictionary in Python


In this example, we will learn how to add an item to the dictionary in Python.

Source Code

mydict = {
  'name': 'Steven',
  'age': 24,
  'ID': 123456
}

mydict['grade'] = 'A'
print(mydict)

Output:

{'name': 'Steven', 'age': 24, 'ID': 123456, 'grade': 'A'}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments