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

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.

Voters
Profile icon
IntelDS
Comments
hotnewtop
Profile icon
tankerguy1917

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