Variable problems

Hi, I’m working on a project through CodeHs and I keep running into this same problem. I keep getting an error saying that I’m refrencing a local variable before its assignment, but I have already declared it globaly. Additionally, I can change or reset the value of prety much any other global value, but when I try to set it equal to the preexisting value minus one it bugs out. I have already had problems with this happening with other variables as you can see from this atrocious code I’ve had to write to get around these problems, but this one I don’t know how I can fix. Any help would be appreciated.

See this explanation: Programming FAQ — Python 3.12.2 documentation

Please first read the pinned thread in order to understand how to format code properly for the forum; screenshots are inherently harder to read and can’t be copied and pasted from for discussion.

Then read here:

as this is an extremely common issue. The short version is that simply writing the name guesses_left outside the function does not mean that the name guesses_left will be a global variable everywhere within the code.