Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python filter array

myList = [1, 2, 3, 4, 5]
filtered = list(filter(lambda x: x%2==0, myList))
#                      ^ ^ ^ ^ ^ ^ ^ ^ ^
#                 function that returns boolean

# OR

filtered = [x for x in myList if x%2==0]
#                                ^ ^ ^
#                              condition
 
PREVIOUS NEXT
Tagged: #python #filter #array
ADD COMMENT
Topic
Name
5+7 =