data = {'one': '1', 'two': '2', 'three': '3', 'four': '4', 'five': '5'}
keys = ('one', 'four')
unwanted = set(keys) - set(data)
for unwanted_key in unwanted: del data[unwanted_key]
The output that I want is:
data = {'two': '2', 'three': '3', 'five': '5'}
What am I doing wrong?
I am using the code of this accepted answer.