Is there any efficient shortcut method to delete more than one key at a time from a python dictionary?
For instance;
x = {'a': 5, 'b': 2, 'c': 3}
x.pop('a', 'b')
print x
{'c': 3}
Is there any efficient shortcut method to delete more than one key at a time from a python dictionary?
For instance;
x = {'a': 5, 'b': 2, 'c': 3}
x.pop('a', 'b')
print x
{'c': 3}
Use the del
statement:
x = {'a': 5, 'b': 2, 'c': 3}
del x['a'], x['b']
print x
{'c': 3}