def filter_divisible_by_three(iterable):
    for item in foo:
        if item % 3 != 0:
            yield item
new_foo = filter_divisible_by_three(foo)
Python: create a function to modify a list by reference not value