This is completely artificial and there is really no reason for doing it this way:
>>> l = [0, 1, 2]
>>> n = len(l)
>>> [[l[(j+i)%n] for j in range(n-1)] for i in range(n)]
[[0, 1], [1, 2], [2, 0]]
It rotates around the list which is what %
will do, perhaps more obvious with a longer list:
>>> l = [0, 1, 2, 4, 5]
>>> n = len(l)
>>> [[l[(j+i)%n] for j in range(n-1)] for i in range(n)]
[[0, 1, 2, 4], [1, 2, 4, 5], [2, 4, 5, 0], [4, 5, 0, 1], [5, 0, 1, 2]]
If you really do need this rotational output then suggest looking into collections.deque()
.