• d.pop(key) -- consider using this if you need the value for the item being deleted, and/or you want to specify a default value and don't want an exception raised if the key doesn't exist.
    e.g., value = d.pop(key, None)
  • del key -- consider using this if you are certain that the key exists (or you expect an exception if it doesn't), and you don't need the value of the item being deleted.
    e.g., del key

From the official Python language documentation:

del d[key] Remove d[key] from d. Raises a KeyError if key is not in the map.

pop(key[, default]) If key is in the dictionary, remove it and return its value, else return default. If default is not given and key is not in the dictionary, a KeyError is raised.

https://docs.python.org/3/library/stdtypes.html#mapping-types-dict

Answer from Wang Dingwei on Stack Overflow
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
Remove an Item from a Dictionary in Python: pop, popitem, clear, del | note.nkmk.me
April 27, 2025 - The pop() method removes the item associated with the specified key from the dictionary and returns its value. Built-in Types - dict.pop() โ€” Python 3.13.3 documentation
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python-dictionary-pop-method
Python Dictionary pop() Method - GeeksforGeeks
May 9, 2025 - Explanation: while loop repeatedly removes and prints the first key-value pair from the dictionary using pop() until the dictionary is empty. ... Python dictionary methods is collection of Python functions that operates on Dictionary.Python ...
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ difference between "del" and "pop" for removing items from a dictionary.
r/learnpython on Reddit: Difference between "del" and "pop" for removing items from a dictionary.
February 18, 2019 -

I have a dictionary and I wanted to remove one item and documentation mentioned that I can use:

phonebook = {

"John" : 938477566,

"Jack" : 938377264,

"Jill" : 947662781

}

del phonebook["John"]

print(phonebook)

or

phonebook = {

"John" : 938477566,

"Jack" : 938377264,

"Jill" : 947662781

}

phonebook.pop("John")

print(phonebook)

What's the difference between those two?

๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ python-pop
How to Use the Python pop() Method | DataCamp
July 31, 2024 - When we use the pop() method to remove the first or any other element, it works in O(n) time because it involves removing an element and shifting the other elements to a new index order. Check out our Analyzing Complexity of Code through Python tutorial to learn more about time complexity in Python. The pop() method in dictionaries is highly efficient due to the implementation of the underlying hash table.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ pop-python
How to Use `.pop()` in Python Lists and Dictionaries | DigitalOcean
July 24, 2025 - Use .pop() when you need to process elements from a list or dictionary and remove them as you go. This is especially useful in algorithms that consume data, such as parsing, filtering, or transforming collections, ensuring that processed items are not revisited or left behind in your data ...
Find elsewhere
๐ŸŒ
Stack Abuse
stackabuse.com โ€บ python-how-to-remove-a-key-from-a-dictionary
Python: How to Remove a Key from a Dictionary
September 19, 2021 - Unlike pop(), no value is returned when deleted. If you are looking to preserve the existing dictionary input, you can find the next section to be useful. The previous methods update a dictionary in-place, meaning that the key-value pair is destroyed. If the original key needs to be preserved, ...
๐ŸŒ
Medium
medium.com โ€บ @python-javascript-php-html-css โ€บ efficiently-removing-keys-from-python-dictionaries-5edc9a4ab9b3
Remove Keys from Python Dictionaries Effectively
August 24, 2024 - The most efficient method depends on the specific use case, but dictionary.pop(key, None) is generally a concise and safe option for single key removal. ... Removing keys from a Python dictionary safely and efficiently can be achieved through ...
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 1721908 โ€บ what-s-that-difference-between-pop-and-del-keyword-in-python-dictionaries
What's that difference between pop() and del keyword in python dictionaries? | Sololearn: Learn to code for FREE!
pop doesn't only delete, it also returns, what it deletes. So you can write a statement like: x = your_list.pop() ... The logic is the same. If you use del on a dictionary item, it is just deleted and that was it.
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ deleting from a dictionary best practice?
Deleting from a dictionary best practice? : r/learnpython
May 30, 2020 - Technically del is very slightly faster. Most of that very slight advantage is because .pop has an extra attribute lookup. In python we don't worry about microoptimzation, so don't let that factor into your decision.
๐ŸŒ
Medium
allwin-raju.medium.com โ€บ understanding-pop-remove-and-del-in-python-abb9e0223706
Understanding pop, remove, and del in Python | by Allwin Raju | Medium
December 1, 2024 - Raises an error if the index (list) or key (dictionary) doesnโ€™t exist. If youโ€™re working with lists, pop() can remove an element at a specific position (default is the last element).
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ ref_dictionary_pop.asp
Python Dictionary pop() Method
Python Dictionaries Access Items Change Items Add Items Remove Items Loop Dictionaries Copy Dictionaries Nested Dictionaries Dictionary Methods Dictionary Exercises Code Challenge Python If...Else
๐ŸŒ
Career Karma
careerkarma.com โ€บ blog โ€บ python โ€บ python remove key from a dictionary: a complete guide
Python Remove Key from a Dictionary: A Complete Guide: A Complete Guide | Career Karma
December 1, 2023 - The pop() method accepts a key name as argument whereas โ€œdelโ€ accepts a dictionary item after the del keyword. In this guide, we discuss how to remove a key from a Python dictionary.
๐ŸŒ
Data Science Parichay
datascienceparichay.com โ€บ home โ€บ blog โ€บ python dictionary pop vs popitem
Python Dictionary Pop vs Popitem - Data Science Parichay
October 4, 2020 - They are mutable and hence we can ... data structures in python. The python dictionary functions pop() and popitem() are used to remove items from a dictionary....
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ what-is-difference-between-del-remove-and-pop-on-python-lists
Difference Between Del, Remove and Pop in Python Lists - GeeksforGeeks
July 23, 2025 - del is a keyword and remove(), and pop() are in-built methods in Python. The purpose of these three is the same but the behavior is different.
๐ŸŒ
Sentry
sentry.io โ€บ sentry answers โ€บ python โ€บ delete element from a dictionary in python
Delete element from a dictionary in Python | Sentry
August 15, 2023 - For example: products = {"apples": ... method. The main difference between this and del is that dict.pop will return the value of the removed dictionary element....
๐ŸŒ
SitePoint
sitepoint.com โ€บ python hub โ€บ remove dictionary items
Python - Remove Dictionary Items | SitePoint โ€” SitePoint
Remember that removing items from a dictionary is an immediate operation - once removed, the key-value pair is gone unless you've stored it elsewhere. If you try to remove a non-existent key using del, Python will raise a KeyError.