fork download
  1. x = 1
  2.  
  3. def foo():
  4. x = 2
  5.  
  6. def bar():
  7. global x
  8. print("bar:", x)
  9.  
  10. def baz():
  11. nonlocal x
  12. print("baz:", x)
  13.  
  14. bar()
  15. baz()
  16.  
  17. foo()
Success #stdin #stdout 0.02s 28384KB
stdin
Standard input is empty
stdout
bar: 1
baz: 2