> > > > You can write code like this: > > from operator import add > print reduce(add, filter(lambda x: x%2==0, xrange(10))) > > to print the sum of even numbers less than 10 > instead of: > tot = 0 > for i in xrange(10): > ....if i%2 == 0: > ........tot += i > print tot > > ... >
I would prefer LC anyway: >>> sum(i for i in range(0,10,2)) 20 -- ~l0nwlf _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers