December 2017
Beginner
412 pages
10h 8m
English
Here is the same bird-watching observation file that we saw in Set Example: Arctic Birds:
| | canada goose |
| | canada goose |
| | long-tailed jaeger |
| | canada goose |
| | snow goose |
| | canada goose |
| | long-tailed jaeger |
| | canada goose |
| | northern fulmar |
Suppose we want to know how often each species was seen. Our first attempt uses a list of lists, in which each inner list has two items. The item at index 0 of the inner list contains the species, and the item at index 1 contains the number of times it has been seen so far. To build this list, we iterate over the lines of the observations file. For each line, we search the outer list, looking for the species on that line. If we find that the species occurs in the list, we add one to ...
Read now
Unlock full access