When I have exec() in defined function it is not working ('NameError: name 'a' is not defined'):
def abc():
qwerty = "a = 2"
exec(qwerty)
abc()
print(a)
but, when I won't use def, it is working:
qwerty = "a = 2"
exec(qwerty)
print(a)
How can I "repair" it, or are there other similar solutions? (I can't execute this at start, I need to call that function in the middle of the program)