Oltmans <[email protected]> writes:
> a = [ [1,2,3,4], [5,6,7,8] ]
>
> Currently, I'm iterating through it like
>
> for i in [k for k in a]:
> for a in i:
> print a
I would prefer:
for i in a:
for v in i:
print v
i.e., not messing with a and avoiding an additional list.
> but I was wondering if there is a shorter, more elegant way to do it?
I can't see any, but if you need to save space, you may use
for v in (e for l in a for e in l):
...
-- Alain.
--
http://mail.python.org/mailman/listinfo/python-list