Hi I’ve been working on this level for about 3 months now I’ve read all of the brittle morale forums and still cant seem to get it right
this is my current 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)
although you may be receiving an error “enemy is not defined” because strongest is being initialized to “enemy” although “enemy” hasn’t been defined before
if that is the case you can initialize strongest to “None”
you’re welcome for the welcome
also if you’ve completed the level you can mark any comment as “solution” and it will close the topic. Helps keep the discourse a bit less cluttered.