AVD
April 24, 2018, 2:31pm
1
Hi, I need help.
My hero is not even moving.
I have no idea what else to do.
enemies = hero.findEnemies()
enemyIndex = 0
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.type == 'shaman':
while enemy.health > 0:
hero.attack(enemy)
enemyIndex += 1
AVD
April 24, 2018, 2:35pm
2
Guys never mind.
The code works when i click submit.
Im having issues with this level please help me.
findEnemies returns a list of all your enemies.
Only attack shamans. Don’t attack yaks!
enemies = hero.findEnemies()
enemyIndex = 0
Wrap this section in a while loop to iterate all enemies.
While the enemyIndex is less than the length of enemies
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.type == ‘shaman’:
while enemy.health > 0:
hero.attack(enemy)
Remember to increment enemyIndex
enemiIndex+=1
sorry in advance i don’t know how to do it the way so it’s easy to read
# findEnemies returns a list of all your enemies.
# Only attack shamans. Don't attack yaks!
enemies = hero.findEnemies()
enemyIndex = 0
# Wrap this section in a while loop to iterate all enemies.
# While the enemyIndex is less than the length of enemies
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.type == 'shaman':
while enemy.health > 0:
hero.attack(enemy)
# Remember to increment enemyIndex
enemiIndex+=1
sorry about that.
No worries!
Your enemiIndex+=1 is misspelled (needs a ‘y’) and is outside of the while loop…you need to indent it with 4 spaces.
1 Like
Thanks for the help @dedreous it worked! again thank you.
1 Like
I tried that and it still doesn’t work.
findEnemies returns a list of all your enemies.
Only attack shamans. Don’t attack yaks!
enemies = hero.findEnemies()
enemyIndex = 0
Wrap this section in a while loop to iterate all enemies.
While the enemyIndex is less than the length of enemies
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.type == ‘shaman’:
while enemy.health > 0:
hero.attack(enemy)
# Remember to increment enemyIndex
enemyIndex+=1
Howdy and welcome to the forum! Please post your code properly formatted. This article will help with that:
Formatting your code before posting code is essential to our community, and if you don’t we might not be able to help Everyone must know how to format ALL of your code properly. It’s really easy and only requires a very small amount of effort.
[Screen Shot 2020-04-04 at 11.55.07]
To post your code from the game , use the </> button or it won’t format properly. When you click the </> button, the following will appear:
[Screen Shot 2020-04-04 at 11.55.36]
Please paste ALL …
3 Likes
hi and welcome to the forum! nice profile pic