I have a question about my python code in Jupyter Notebook.
Here is a piece of code that can work well.
res = 1 def add(x): return x + res
Here is a piece of code that meets error on line 3 ("UnboundLocalError: local variable 'res' referenced before assignment").
res = 1 def add(x): res = max(res, x) return x + res
Why the second piece of code has error? res has been declared already, right?