assign exec function to variable python

Solutions on MaxInterview for assign exec function to variable python by the best coders in the world

showing results for - "assign exec function to variable python"
Jacopo
17 Mar 2018
1old_string = "didn't work"
2new_string = "worked"
3
4def function():
5    exec("global old_string; old_string = new_string")
6    print(old_string)
7
8function()