[BangPypers] which one is the best pythonic way .
Srinivas Reddy Thatiparthy
srinivas_thatiparthy at akebonosoft.com
Tue Feb 9 05:52:36 CET 2010
I have written four solutions to a problem(self explanatory) ,out of
them ,which one is the pythonic way of doing and
is there any other ways of solving it?
1.sum([i for i in range(1000) if i%3==0 or i%5==0])
2.gen=(i for i in range(1000))
sum([i for i in gen if i%3==0 or i%5==0])
3.sum(filter(lambda a:a%3==0 or a%5==0,range(1000)))
if count%3==0 or count%5==0:
sum([i for i in generator(1000)])
~ Srini T
More information about the BangPypers