A Fine Mint - Failure to Loop (IE11)

I have logged into the game and played a few levels on IE11 to determine its performance. It’s been doing well far better than Firefox and/or Chrome.

I did my piece of code here, blurred as a spoiler, to prevent those who wish to increase knowledge by coding their way.

[spoiler]def pickUpCoin():
coin = hero.findNearestItem()
if coin:
hero.moveXY(coin.pos.x, coin.pos.y)

Write the attackEnemy function below.

def attackEnemy():
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)

while True:
attackEnemy()
pickUpCoin()
[/spoiler]

When all was done, I clicked Submit. I did it thrice to see the active result. The problem was that as the hero, Anya, loops around the coinage a full 3/4ths, attacks one enemy, the game stops. It does not continue to loop as expected; instead, I was forced to click on Submit hoping to pass this level.

Any thoughts as to how to solve this problem?