For example, if you are expecting a list with one integer and I give you a plain old integer (not in a list), it won't work.Exercise 1: Revise a previous program as follows: Read and parse the "From" lines and pull out the addresses from the line.
Converting a dictionary to a list of tuples is a way for us to output the contents of a dictionary sorted by key: tuples, but this time we want to sort by value, not key.
Once we have constructed the list with the value-key tuples, it is a simple matter to sort the list in reverse order and print out the new, sorted list.
Then sort the list in reverse order and print out the person who has the most commits.
Exercise 2: This program counts the distribution of the hour of the day for each of the messages.
Your program should not count spaces, digits, punctuation, or anything other than the letters a-z.
Find text samples from several different languages and see how letter frequency varies between languages.
I have focused on lists of tuples, but almost all of the examples in this chapter also work with lists of lists, tuples of tuples, and tuples of lists.
To avoid enumerating the possible combinations, it is sometimes easier to talk about sequences of sequences.
The number of variables on the left and the number of values on the right must be the same: As you should expect from a dictionary, the items are in no particular order.
However, since the list of tuples is a list, and tuples are comparable, we can now sort the list of tuples.