The following script produces a "local variable 'var' referenced before assignment" error:
def func1():
var = var + 1
var = 1
func1()
How would you suggest to correct the code? Why does this error occur when the variable is declared in the script before the function is called?