Consider the following dictionary, d:
d = {\'a\': 3, \'b\': 2, \'c\': 3, \'d\': 4, \'e\': 5}
I want to return the first N key:value pairs f
You can approach this a number of ways. If order is important you can do this:
for key in sorted(d.keys()): item = d.pop(key)
If order isn't a concern you can do this:
for i in range(4): item = d.popitem()