filter(function, sequence) => list
Constructs a list from those elements of a sequence for which the function returns true. The sequence argument may be either a sequence, a container which supports iteration, or an iterator. If sequence is a string or a tuple, the result also has that type; otherwise it is always a list. If function is None, the identity function is assumed, that is, all elements of sequence that are false (zero or empty) are removed.
filter(function, sequence) is equivalent to the list comprehension
[item for item in sequence if function(item)]
if function is not None and
[item for item in sequence if item]
if function is None.