def bar(x):
    return list(eval('x') + x for i in range(3))
bar(5)

def baz(x):
    return list(eval('x') for i in range(3))
baz(5)
Undefined global in list generator expression using python3, works with python2, what changes are needed?