How to Remove Item with Specified Key Name in Python


In this example, we will learn how to remove the item with the specified key name using the pop() method in Python.

Source Code

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

mydict.pop('age')
print(mydict)

Output:

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