Rewrite the following snippet of code so it can run in modern python versions.
def foo(my_list):
    result = []
    for element in my_list:
        if 'foo' in element
            result.add('foo')
    return result
def foo(my_list):
    result = []
    for element in my_list:
        if 'foo' in element:
            result.append('foo')
    return result