def f(): global x = 1 # SyntaxError: invalid syntax
print(x) # NameError: name 'x' is not defined def f(): global x x = 1 print(x) # NameError: name 'x' is not defined f() print(x) # 1