a sequence question

Chris Wright wrightca at hotmail.com
Fri Jan 28 14:59:45 CET 2005


1) I want to iterate over a list "N at a time"
sort of like:

# Two at a time... won't work, obviously

 >>> for a, b in [1,2,3,4]:
... 	print a,b
Traceback (most recent call last):
   File "<interactive input>", line 1, in ?
TypeError: unpack non-sequence

Is there a nifty way to do with with list comprehensions,
or do I just have to loop over the list ?

cheers and thanks

chris wright

More information about the Python-list mailing list