Python: Filter a dictionary
- by Adam Matan
Hi,
I have a dictionary of points, say:
>>> points={'a':(3,4), 'b':(1,2), 'c':(5,5), 'd':(3,3)}
I want to create a new dictionary with all the points whose x and y value is smaller than 5, i.e. points 'a', 'b' and 'd'.
According to the the book, each dictionary has the items() function, which returns a list of (key, pair) tuple:
…