I write below code in python(version 3.6.2):
def test():
temp = 'c=1'
exec(temp)
print(c)
test()
when run it, I get below error:
NameError: name 'c' is not defined
but when run below code :
temp='a=1'
exec(temp)
print(a)
it print 1.
How do I fix this?