Zip with sequences of diffrent length

Nickolay Kolev nmkolev at uni-bonn.de
Mon Apr 26 12:51:32 EDT 2004


Hi all,

I want to make tuples of the elements of a list like this.

l = [1, 2, 3]

Wanted tuples:

(1, 2)
(2, 3)
(3, None)

I can get the first two tuples using zip(l, l[1:]). How do I get the 
last one?

Many thanks in advance,
Nicky



More information about the Python-list mailing list