Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

( health ) Variables ain't working as it should be


Hey there is a bug about health’s variable in while loop

if i made the code as this:

    hp =
    fullhp = self.maxHealth
    while hp >= fullhp :
        self.say("You stupid Ogres LOL!")

it stuck inside an inf loop

but if i make it as this

while >= self.maxHealth :
    self.say("You stupid Ogres LOL!")
self.moveXY(22, 15)

it does works , try it yourself , and sorry for my bad english tough


It’s because you redefined the variable. it never changes unless you change it.

you’d have to do something inside the while loop like

while hp >= fullhp:
    hp =


Also, since hp is never > maxHealth, can just compare them as:

while hp == fullhp: