+ 2

% Operation

I don't know why the out put is [], could anyone tells me? Thanks! https://code.sololearn.com/cAl8Ac0qcMUI/?ref=app

3rd Jul 2018, 10:20 AM
Outro
Outro - avatar
2 odpowiedzi
+ 1
https://docs.python.org/3/library/itertools.html#itertools.takewhile In the implementation you can see 2 things.... - It’s a generator so for i in takewhile(...): print(i) - The generator stops when a condition is false (the else: break part) Use filter instead which is built in... print(list(filter(lambda x: x % 2 == 0, nums)))
3rd Jul 2018, 10:30 AM
TurtleShell
TurtleShell - avatar
0
TurtleShell Thank you very much, I got it
3rd Jul 2018, 10:44 AM
Outro
Outro - avatar