[BangPypers] Issue with list comprehension

Asokan Pichai pasokan at gmail.com
Thu Oct 31 07:52:18 CET 2013


import itertools

def fib():
  a, b = 0, 1
  while True:
      yield b
      a, b = b, a+b

print sum(itertools.takewhile(lambda x: x < 400, fib))
-----------------------
I tried the above; and it worked too (986)

Asokan Pichai


More information about the BangPypers mailing list