Using dict.pop
:
d = {'some': 'data'}
entries_to_remove = ('any', 'iterable')
for k in entries_to_remove:
d.pop(k, None)
More Related Contents:
- Adding a element in dictionary which consist of dictionaries.
- I am trying to modify a dictionary value using the exec function
- How do I merge two dictionaries in a single expression (take union of dictionaries)?
- How to copy a dictionary and only edit the copy
- Replace values in a pandas series via dictionary efficiently
- What’s a correct and good way to implement __hash__()?
- How to keep track of class instances?
- How do I format a string using a dictionary in python-3.x?
- How to add multiple values to a dictionary key in python?
- Thread Safety in Python’s dictionary
- python filter list of dictionaries based on key value
- Extract subset of key-value pairs from dictionary?
- String to Dictionary in Python [duplicate]
- Merging dictionary value lists in python
- Setting a value in a nested Python dictionary given a list of indices and value
- Add a new item to a dictionary in Python [duplicate]
- How to iterate through a list of dictionaries in Jinja template?
- Python: Reducing memory usage of dictionary
- How to split dictionary into multiple dictionaries fast
- Using a dict to translate numbers to letters in python
- How can I make a dictionary (dict) from separate lists of keys and values?
- How to merge dicts, collecting values from matching keys?
- Merge several Python dictionaries
- Is self.__dict__.update(**kwargs) good or poor style?
- How can I avoid “RuntimeError: dictionary changed size during iteration” error?
- Why updating “shallow” copy dictionary doesn’t update “original” dictionary? [duplicate]
- dataframe to dict such that one column is the key and the other is the value [duplicate]
- Is the order of a Python dictionary guaranteed over iterations?
- How can I make a list of dictionaries according to the Cartesian product of values in a source dictionary (“explode” the dictionary)?
- why dict objects are unhashable in python?