I am new to Python but I am experienced Java programmer. I cant figure why in below code the UnboundLocalError refers to a but not b.
def outer():
a = str()
b = list()
def inner():
b.append(a)
if len(a)==0:
a = 'text'
inner()
inner()
>>>outer()
3 b = list()
4 def inner():
----> 5 b.append(a)
6 if len(a)==0:
7 a = 'text'
UnboundLocalError: local variable 'a' referenced before assignment