Ask coding questions

← Back to all posts
Can someone help?
LisaForsythe

This is my student's code, and we can't figure out where the problem is.

Voters
LisaForsythe
Comments
hotnewtop
SixBeeps

My Python knowledge is subpar, but I believe you need to globalize the variable first before performing operations on it, instead of doing it at the same time. So:

LisaForsythe

@SixBeeps
Thank you so much! That worked

TheDNAHero

Just do guess+=1 instead of global guess+=1, same thing all the global variables

LisaForsythe

@TheDNAHero
When we take global out, it says the variable can't be accessed.