UnboundLocalError: Local Variable Referenced Before Assignment in Python
UnboundLocalError (“local variable referenced before assignment”) means a function reads a variable that Python has decided is local, before that local variable has been given a value. It almost always happens because the function assigns to a name that also exists outside it. Newer versions of Python, including the Python 3.12.5 I used for every … Read more >>