Python: While loop runs infinitely

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)

Does this look like the issue you’re experiencing?

1 Like

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