UnboundLocalError at / cannot access local variable 'stud' where it is not associated with a value

UnboundLocalError at /

cannot access local variable ‘stud’ where it is not associated with a value

We cannot help you unless you share details of what you are doing.
Please share the code that causes this error as preformatted text, select your codes text and use the </> button

however – a hint.

when you do somethign like:

def a_function():
    ...
    ...
    x = 5
    ...

when the function is compiled, the x is marked as a local variable, but it doesn’t have a value until that line where is it set.

So you usually get an UnboundLocalError when you try to access the variable before the line where it was set.

If you do the same thing outside a function, then it would be a NameError, as it wouldn’t even know that that name exists.