I had this code:
def test(variable, customCode = ""):
if variable > 1:
print(">1")
if customCode != "":
exec(customCode)
if foo == 1:
print("Success")
numb = 12
code = "if variable > 1: foo = 1"
test(numb, code)
Which, when executed, gives this error:

So, then, I added foo = 0 at the beginning of the code, and got this output:

Now, obviously, it should also be outputting Success, but it isn't.
What's the issue?
Using Python 3.
>1then a line break andSuccess.2.7.6and3.4.3(in Python3 it failed miserably), sorry I didn't mention that. Your answer got me curious — would that be considered a form of scoping?