Sarven Shepherd help

this is my code. I think it’s right, but my hero always dies. My friend put in the same code, and he passed it, but I can’t
here is my code
enemies = self.findEnemies()
enemyIndex = 0

while enemyIndex < len(enemies):    
    enemy = enemies[enemyIndex]
    if enemy.type != "sand-yak":
        while >0:
            if self.isReady("cleave") and self.distanceTo(enemy) <10:
    enemyIndex = enemyIndex +1

self.moveXY(40, 32)

Could it be because I don’t have enough health? If that’s the case I don’t have enough gems to buy anything.
Please help
If I need crystals, how do I get like free gems so I can Buy better armor? I need better armor to pass this level. I need gems to buy new armor.

How much health do you have? I completed it with ~600 health.

If you have a shield that bashes, use it. Cleaving with the long sword is nearly useless (takes too long, only deals 15 damage against enemies with 60+ health).

If you have around 600+ health right now, but no decent primary weapon, I suggest that you save up for a sword like the Kithsteel Blade or higher. If not, I’m not even sure how you survived some of the previous levels (or you may have skipped those, I don’t know).

If you need gems, you could simulate games. The first few hundred gems come pretty quickly, though after a few thousand simulations earning gems becomes very slow. (More info here.) Or you could play the repeatable levels.