attribuer une fonction exec à la variable python

old_string = "didn't work"
new_string = "worked"

def function():
    exec("global old_string; old_string = new_string")
    print(old_string)

function()
AlbaOpus