Hi @TEO Welcome to the discourse

I formatted the for you but next time pls formate the code like the link shown here
while True:
enemies = hero.findEnemies()
enemyIndex = 0
while enemyIndex > len(enemies):
enemy = enemies[enemyIndex]
if enemy.type != “sand-yak”:
while enemy.health > 0:
hero.attack(enemy)
enemyIndex +=1
pass
hero.moveXY(x, y)
Your indentation is wrong, after while and if loop you have to put 4 spaces for just press tab.
Hope it helps 