Thursday, January 18, 2018

Using filters in Python



Creates a list of elements for which a function returns true. Here is a short and concise example:

number_list = range(-5, 5)
less_than_zero = list(filter(lambda x: x < 0, number_list))
print(less_than_zero)




More Examples


No comments:

Post a Comment