Answers for "return result from exec python"

1

return result from exec python

the_code = '''
a = 1
b = 2
return_me = a + b
'''

loc = {}
exec(the_code, globals(), loc)
return_workaround = loc['return_me']
print(return_workaround)  # 3
Posted by: Guest on January-26-2021

Python Answers by Framework

Browse Popular Code Answers by Language