Shield Rush issue

Health starts at 889

executing code:

# Survive both waves by shielding and cleaving.
# When "cleave" is not ready, use your shield skill.
# You'll need at least 142 health to survive.

loop:
    enemy = self.findNearestEnemy()
	if self.isReady("cleave"):
	    self.cleave(enemy)
	else:
	    self.shield()

code complete:

shield does nothing or cleave.

I watched the “Help” video and i have the same code.

used all my gems to improve armor and shield.

What am i doing wrong?

You forgot to check if there is an enemy. Add an if enemy: statement.

    enemy = self.findNearestEnemy()
    if (enemy):
        if self.isReady("cleave"):
            self.cleave(enemy)
        else:
            self.shield()

ok so this did work, but why in the Help video, if (enemy) statement is left out and code runs successfully?

The level may have changed slightly since the video was made, causing there to be times when there are no enemies on screen.