# unbound local error
a = "Hello"
def change():
print(a) #python create "a" local variable
a = 2 # a variable assignment
change() #local variable 'a' referenced before assignment
------------------------------------------------
UnboundLocalError: local variable 'a' referenced before assignment
理解Python的UnboundLocalError(Python的作用域) | 卡瓦邦噶!
全局变量报错:UnboundLocalError: local variable 'l' referenced before assignment | 菜鸟教程