# filter

filter(function, iterable)

Construct an iterator from those elements of iterable for which function returns true. iterable may be either a sequence, a container which supports iteration, or an iterator. If function is None, the identity function is assumed, that is, all elements of iterable that are false are removed.



import random

def filter(bool_func, seq):
filtered_seq = []
for eachitem in seq:
if bool_func(eachitem):
filtered_seq.append(eachitem)
return filtered_seq

def odd(n):
return n % 2

allNums = [i for i in range(100)]
random.shuffle(allNums)
print(filter(odd, allNums))