Skip to content
local variable 'x' defined in enclosing scope on line 3 referenced before assignment
Profile icon

For some reason, line 15 throws up an error when I try to do x+=1 even though I have already given x a value on line 3. I tried looking this up and I only found stuff about the LEGB rules and nothing about how to fix it. Sorry if this is really easy to fix and I wasted your time.

You are viewing a single comment. View All
Profile icon

Hmm, I don't know what's wrong. Maybe try
return x
at the end of the movecheck function?
Hope this helps :)