On 05/09/10 07:09, Günther Dietrich wrote: > > Why not this way? > >>>> a = [[1,2,3,4], [5,6,7,8]] >>>> for i in a: > .... for j in i: > .... print(j) > .... > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > > Too simple?
IMHO that's more complex due to the nested loop, though I would personally do it as: a = [ [1,2,3,4], [5,6,7,8] ] from itertools import chain for i in chain.from_iterable(a): print i so it won't choke when 'a' is an infinite stream of iterables. -- http://mail.python.org/mailman/listinfo/python-list