The following python code gives an error. Why isn't it referencing the global variable a ?
a = 10
def b(x):
if(x == True):
a = 2
return a
print(b(False))
The error:
Traceback (most recent call last):
File "<string>", line 8, in <module>
File "<string>", line 6, in b
UnboundLocalError: local variable 'a' referenced before assignment
>