Retain all entries except for one key python

for key, value in your_dict.items():
    if key not in your_blacklisted_set:
        print value

the beauty is that this pseudocode example is valid python code.

it can also be expressed as a list comprehension:

resultset = [value for key, value in your_dict.items() if key not in your_blacklisted_set]

Leave a Comment