def test(a):
if a>1:
x=0
elif a<1:
y=1
else:
x=2
print(x)
return 0
Why test(2) is ok but test(0) will raise the following error?
local variable 'x' referenced before assignment
I guess when test(2) x was defined, but run test(0) x was not defined, but also want to know more about the cause