Kindly show me a better way to do it

superpollo utente at esempio.net
Sat May 8 16:53:33 EDT 2010


Oltmans ha scritto:
> Hi, I've a list that looks like following
> 
> 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:

i think you used te a identifier for two meanings...

> 		print a
> 
> but I was wondering if there is a shorter, more elegant way to do it?


add = lambda a,b: a+b
for i in reduce(add,a):
     print i



More information about the Python-list mailing list