Help on Sarven Shepherd[SOLVED]

Please help me in this code=The code I typed is not working no matter how much I try.
Here is the code

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

    # Wrap this logic in a while loop to attack all enemies.
    # Find the array's length with:  len(enemies)
while enemyIndex < len(enemies):
    enemy = enemies[enemyIndex]
    # "!=" means "not equal to."
if enemy.type != "sand-yak":
        # While the enemy's health is greater than 0, attack it!
    while > 0:

You have to increment (increase by one) enemyIndex inside the while enemyIndex < len(enemies): loop.
You should add enemyIndex += 1 to increase enemyIndex. At the moment, enemyIndex will stay at 0 and you’ll get an infinite loop.
Make sure you put enemyIndex += 1 inside the second while loop, but outside the if enemy.type != “sand-yak”: statement.

Your advice was good but I did the level with 2 lines of code.`while True:

hero.buildXY("fire-trap", 36, 30)
hero.buildXY("fire-trap", 59, 31)


So, you learnt to plant bombs and didn’t learn incrementin?))

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.