Python raises UnboundLocalError: cannot access local variable 'x' where it is not associated with a value when a function reads a name that Python has decided is local to that function, but the line that gives it a value has not run yet. Any assignment to a name anywhere inside a function (inclu...
Source: [Dev.to](https://dev.to/mfaysaldev/unboundlocalerror-cannot-access-local-variable-where-it-is-not-associated-with-a-value-in-python-b5l)