Python: While loop runs infinitely


#1

The following code results in an infinite loop, even though the selected enemy is clearly dead. As far as I can tell, the syntax is correct (I’m a JS coder, using CC.com to learn Python).

This is as stripped-down as I can make the code to reproduce the issue; I’m aware that without a loop my hero won’t attack any other enemies.

Am I doing something wrong? Any help is appreciated.

e = self.findNearest(self.findEnemies())
while e.health > 0:
    self.attack(e)


#2

Does this look like the issue you’re experiencing?


#3

That looks like it exactly! I’ve added my experience to the bug report there. Thanks.