There are three dictionary methods for extracting certain data. .keys() returns the keys in the dictionary as a list, and .values() returns the dictionary values as a list.
>>> simpsons.keys() # .keys() returns list of keys['Homer', 'Lisa', 'Marge', 'Bart']>>> simpsons.values() # .values() returns list of values[36, 8, 35, 10]
On the other hand, .items() returns both keys and values, but as a list of (key, value) tuples:
>>> simpsons.items() # .items() returns a list of key, value tuples[('Homer', 36), ('Lisa', 8), ('Marge', 35), ('Bart', 10)]
Dictionaries are orderless, but often it's necessary to impose a certain order (e.g., alphabetical) when processing dictionary entries. You achieve this by sorting the keys. See Sorting for details.