Global name '...' not defined

I was fiddling around with the GoPiGo3 trying to make it follow a line, and every time it passed an “intersection” (all black) it would add 1 to a variable I made to log how many it passed over. It would always turn on the first intersection it passed no matter what number I put to turn on. I then made functions to make everything cleaner, and maybe try to get it to work, but now it spits out an error saying the variable I made wasn’t defined, title of post is the error message. Here’s the error and here’s the pile of spaghetti i call my code. Thanks for your time in advance.

I’m taking a look.
Rebuilding your code from the image you shared

Well, if it’s any consolation, the problem is not with your code but with mine. First time I see this situation too.
Interestingly, if I open the Python panel and copy/paste the code there into a cell in the Python editor, it works there.
Is that a possibility for you?

Sorry, it’s been a few days. I play with these in my robotics class in school, I’ll try that and see if it works, Thanks

hey @kyfang
How is it going?
I do have a fix for you, if your teacher will let you update the SD card on the robot.
Let me know if you want it (it is available in DexterOS 2.2 already)