Level help: help with Brittle Morale (python) [solved]

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)

you forgot to set the “strongest” variable to the enemy after setting the strongestHealth to enemy.health

I wish I could help but I only know JavaScript. I have completed the level already in JavaScript.

1 Like

around what line is that

about line 15
everything else looks good though

1 Like

your all good

aaaaaaaaaaaaaaaaaaaaaaaaaaaa

1 Like

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”

Also, welcome to the community @paper !

3 Likes

lol where are my manners
welcome to the discourse, paper

3 Likes

I got it OMG FINNALY after 3 MONTHS I missed writing

" strongest = enemy "

man I need new glasses XD

3 Likes

its good to be welcomed in thanks mate

3 Likes

you’re welcome for the welcome :smirk:
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.

scizzors enters the chat

1 Like

NOOOO NOT THE SCISSORS NOT AGAIN I don’t wanna make another crane not again

1 Like

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