Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Please help on level Sarven Desert - Fair Battle


Hi and thanks for reading this :slight_smile:

I’ve been stuck in this level, somehow the total health of soldier is greater than ogres at the begining and I couldn’t even kill one ogre… if it’s something wrong with my code, could someone help me please? Many thank:sweat:

def sumHealth(units):
    totalHealth = 0
    unitsIndex = 0
    while unitsIndex < len(units):
        unit = units[unitsIndex]
        if > totalHealth:
            totalHealth +=
        unitsIndex += 1
        return totalHealth

while True:
    friends = hero.findFriends()
    enemies = hero.findEnemies()
    # Get the total health of your soldiers and the ogres.
    soldierHealth = sumHealth(friends)
    ogreHealth = sumHealth(enemies)
    # Say "Attack" when your side has more total health.
    if soldierHealth != ogreHealth:
        if soldierHealth > ogreHealth:


don’t post the same post in 2 places please. (Especially since you only waited 43 minutes between your posts)


Hi SuperSmacker, sorry for the additional post