In this article you will learn about itertools.pairwise, how to use it, and how to generalise it.
Check out codegolf.stackexchange.com if you want to solve programming puzzles, but with a twist.