Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

filter function in python

# filter is just filters things

my_list = [1, 2, 3, 4, 5, 6, 7]


def only_odd(item):
    return item % 2 == 1	# checks if it is odd or even


print(list(filter(only_odd, my_list)))
Source by book.pythontips.com #
 
PREVIOUS NEXT
Tagged: #filter #function #python
ADD COMMENT
Topic
Name
8+8 =