[SOLVED] Please help on sarven shepard

Please help. I cannot get my hero to move and attack. Here is my code:

Benutze while-Schleifen, um den Oger rauszusuchen

while True:
enemies = hero.findEnemies()
enemyIndex = 0

# Verbaue diese Logik in einer While-Schleife, um alle Gegner anzugreifen.
# ermittele die Länge des Arrays mit: len(enemies)
while True:
    enemy = enemies[enemyIndex]
    # "!=" bedeutet "ist nicht gleich."
    while enemyIndex < len(enemies):
        
        if enemy.type != "sand-yak":
            # Greife den Gegner an, solange seine Gesundheit größer als 0 ist!
            while enemy.health >= 0:
                hero.attack(enemy)
        enemyIndex += 1
    break
# Gehe zwischen den Wellen zurück zur Mitte.
hero.moveXY(40, 32)

I see you have a second while True loop that you don’t need and you break out of it jumping to the last move command skipping the fighting. Move the while enemyIndex < len(enemies): back to the second while True and remove the break. You will probably have to change some indentation too.

while True: # don't want this, replace with other while loop
    enemy = enemies[enemyIndex]  # 
    # "!=" bedeutet "ist nicht gleich."
    while enemyIndex < len(enemies): # move back to the while True line

Thank you so much. I have been stuck on this level for weeks. Code is now running smoothly.

Glad I was able to help! :grinning: