filter a range : filter « Buildin Function « Python Tutorial






print range(-5, 5)

print filter((lambda x: x > 0), range(-5, 5))








13.17.filter
13.17.1.Use filter() and lambda to obtain the set of odd numbers from a sequence
13.17.2.filter a user-defined function
13.17.3.filter(function, sequence) returns a sequence items for which function(item) is true
13.17.4.filter a range