Answer the question
In order to leave comments, you need to log in
Why does it throw an error local variable 'var' referenced before assignment?
Hello, I encountered such a problem as local variable 'var' referenced before assignment. To tell the truth, I do not understand why the code produces an error. thanks in advance!
var = 'hello'
def func():
print(var)
var = 'world'
func()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question