The usual way is to create a new dictionary containing only those elements that you want to save:
new_data = {k: v for k, v in data.iteritems() if v[0] <= 30}
In Python 3.x, use items() instead of iteritems() .
If you need to change the source dictionary in place, you can use for -loop:
for k, v in data.items(): if v[0] > 30: del data[k]
In Python 3.x, use list(data.items()) instead of data.items() .
Sven marnach
source share