The standard library has a module called collections with containers made for jobs that come up again and again: counting things, grouping things and giving a tuple’s positions names. Each saves you a few lines of fiddly code and a few bugs. This lesson covers the first three, and the next covers the rest.
More lessons in Complete Python Programming