10. Collections and Iterators
Python 3 is known to avoid returning lists and dictionaries. If k is a dictionary, in Python 2, k.keys() returns a list of the keys in the dictionary, while in Python 3, k.keys() enables iteration over the keys in something like a for loop. Similarly, k.values() and k.items() returns lists of values or key-value pairs in Python 2, while in Python 3 we can only iterate over the values in a for loop. Python 3 only contains range and it behaves like the Python 2’s xrange and in Python 3, the built-in map behaves like Python 2’s itertools.imap. Therefore in Python 2 and 3, ...