def setcake(taste): global cake cake = taste def caketaste(): print cake #Output is whatever taste was caketaste()
Standard input is empty
Standard output is empty
Traceback (most recent call last): File "prog.py", line 7, in <module> caketaste() File "prog.py", line 5, in caketaste print cake #Output is whatever taste was NameError: global name 'cake' is not defined