Wonderful! I *knew* this cannot be the only way, then I was tinkering with the collections and itertools modules but this is just beautiful.