Take While

Take elements from the start of an array while a condition is true.

Code

General
from itertools import takewhile
return list(takewhile(lambda x: x < threshold, arr))

Parameters

Array

Take while less than threshold

Server

More Python Snippets