On 14/04/12 16:27, Tom Tucker wrote:

Hello all.  Any suggestions how I could easily iterate over a list and
print the output 3 across (when possible)?

Using the step size argument to range:


L = range(12)
>>> for n in range(0,len(L),3):
...    print L[n],L[n+1],L[n+2]
...
0 1 2
3 4 5
6 7 8
9 10 11
>>>

HTH,
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to