The filter() function takes in two arguments: a function and an iterable. It filters the elements of the iterable by calling the given function with each of the iterable's element. It returns an iterator of only those elements that evaluate to True.

filter(function, iterable)

Where, function is a function to be used as a condition, it should return either True or False. The iterable represents the iterable which should be filtered. Both arguments are required.

It returns an iterator object containing the elements that satisfies the given condition.

num_list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 
def is_even(x):
    if x % 2 == 0:
        return True
    else: return False

filtered=filter(is_even, num_list)

Lambda functions are often used with filter functions as the function argument, as they allow for concise filter expressions that would typically otherwise take multiple lines of code to express.

Extract odd numbers from a list of numbers: 

is_odd = lambda x: x % 2 ==1
print(list(filter( is_odd, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])))

greater_than_5 = lambda x: x>5
print(list(filter(greater_than_5, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])))
languages = ('PYTHON', 'css', 'JAVA', 'C++', 'html', 'RUBY', 'javascript', 'KOTLIN')
print(list(filter(lambda x: x.isupper(), languages))) #Extract words whose characters are all uppercase