okay, now it says: type error: cannot read property of legnth of undefined.
can you just, show me your code please?
Iām tired.
like really, i was so coding,
make into
strongestHealth = enemy.health
can you show me the , the proper while enemyIndex < len(enemies):???
if itās correct, please tell me !
yours is correct 2000
but it says length is not defined
show me your code please
hereās mine and it worked
You have one arrow. Make it count!
This should return the enemy with the most health.
def findStrongestEnemy(enemies):
strongest = None
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
strongest = 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)
Welcome to the forum @[username]! This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Donāt forget to read the guidelines if you havenāt yet. Have a great time!
Please be careful that here you canāt post solutions because that would ruin the purpose of playing the game. It would be appreciated if you remove this code if it is working. And always feel free to ask if you need any help