#!/usr/bin/python def func_outer(): x = 2 print('x is', x) def func_inner(): nonlocal x x = 5 func_inner() print('Changed local x to', x)
func_outer() Output: File "nonlocal_var.py", line 6 nonlocal x ^ SyntaxError: invalid syntax Why? Cannon find in google it.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor