Skip to content
Sign upLog in
← Back to Community

Can someone help?

Profile icon
LisaForsythe

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

Voters
Profile icon
LisaForsythe
Comments
hotnewtop
Profile icon
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:

global guess guess += 1
Profile icon
LisaForsythe

@SixBeeps

Thank you so much! That worked

Profile icon
TheDNAHero

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

Profile icon
LisaForsythe

@TheDNAHero

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