150k views
8 votes
Python local variable referenced before assignment.

1 Answer

6 votes

Answer:

may be you are probably calling the variable name before assigning it..

Step-by-step explanation:

this error occurs if your program finds the name of variable used first before assigning the value..

example:

....some code..

print(x)

--some code--

x = something

So the print statement uses x variable before assigning the value. This causes error.

User RCalaf
by
3.0k points