I got a message 'local variable referenced before assignment'
Use external variable and got OK, but failed to assign value
x = 10
y = 10
def some():
print(x)
some()
10
x = 10
y = 10
def some():
x = 100-x+x
print(x)
some()
local variable 'x' referenced before assignment
x = 10
y = 10
def some():
t=100-x
print(t)
some()
90
x = 10
y = 10
def some():
t=100-x
x=t
print(t)
some()
local variable 'x' referenced before assignment
What's the differences ? Expected result should be the same, but failed in 2nd sample.
Does it mean what I can do just read from 'x', no write to 'x' ?