Can anyone help me I don’t understand what the code should be.
This is my code
# You have one arrow. Make it count!
# This should return the enemy with the most health.
def findStrongestEnemy(enemies):
strongest = enemy
strongestHealth = 0
enemyIndex = 0
# While enemyIndex is less than the length of enemies:
while enemyIndex < len(enemies):
# Set an enemy variable to enemies[enemyIndex]
enemy = enemies[enemyIndex]
# If enemy.health is greater than strongestHealth
if enemy.health > strongestHealth:
# Set `strongest` to enemy
# Set strongestHealth to enemy.health
strongestHealth = enemy.health
# Increment enemyIndex
enemyIndex += 1
return strongest
enemies = hero.findEnemies()
leader = findStrongestEnemy(enemies)
if leader:
hero.say(leader)
my hero won’t do anything
2 things.
- In the first line of the function, strongest should start out being defined as
None
. - You have not followed all of the directions. See this line,
# Set 'strongest' to enemy
. You need to do that.
Thank you it work now.
thank you so much
i had the same problem with my code
Me too, thanks
The fact that the singular arrow did 8,947 damage though… I dont wanna be on the wrong side of that guy…
2 Likes
Huh? I just used your code and won!!?
Hi this person is not active anymore so your just wasting your post. And also try not to copy other peoples codes.