On Sun, 09 May 2010 15:17:38 +1000, Lie Ryan wrote: > 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,
What's so complex about a nested loop? And why are you saying that it is "more complex" than the Original Poster's solution, which also had a nested loop, plus a pointless list comprehension? > 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. Neither will a nested for-loop. -- Steven -- http://mail.python.org/mailman/listinfo/python-list