List mapping?

Remco Gerlich scarblac-spamtrap at
Thu Apr 13 10:34:01 EDT 2000

Nick Trout wrote in comp.lang.python:
> while i < len(listargs):
>     tuplist.append( (listargs[i],listargs[i+1]) )
>     i = i+2

> Can I (you!) get rid of the long winded while loop cleverly?!!  :-)

That isn't long winded, in my opinion. And not hard to read.


for i in range(0, len(listargs), 2):
Is one line shorter. I don't think there's a builtin function for making a
list into tuples like that.

Remco Gerlich,  scarblac at
  5:30pm  up 38 days,  4:50,  8 users,  load average: 1.27, 1.42, 1.48

More information about the Python-list mailing list