0
function takewhile has same functioning as filter.so why use it?
1 ответ
+ 1
Filter catches all elements of the iterable that satisfy the predicate, whereas takewhile stops at the first element that doesn't. e.g. if you add nums.append(5) before the last print statement in the example above the output stays the same.