[Solved] Help With Weakest Quickest


i’m having a lot of trouble with levels that uses enemy.health or coin.value, Can someone please explain why this is happening?

,My Code:

# Defeat shamans to survive.

# The function find the weakest enemy.
def findWeakestEnemy():
    enemies = hero.findEnemies()
    weakest = None
    leastHealth = 99999
    enemyIndex = 0
    enemies = hero.findEnemies()
    # Loop through enemies:
    while enemyIndex < len(enemies):
        enemy = enemies[enemyIndex]
        # If an enemy's health is less than leastHealth:
        if enemy.health < leastHealth:    
            # Make it the weakest 
            enemy = weakest
            # and set leastHealth to its health.
            leastHealth = enemy.health
        enemyIndex += 1
    return weakest

while True:
    # Find the weakest enemy with the function:
    weakestShaman = findWeakestEnemy()
    # If the weakest enemy here:
    if weakestShaman:
        # Attack it!


Do weakest=enemy :wink: And weakestShaman=weakest Since there is no such thing as find weakest enemy


Thank you, it worked by replacing enemy = weakest with

weakest = enemy 

But i didn’t Understand why.


Since the other way, it means that the weakest is enemy, but not all enemies are weakest so in the other way the current enemy is the weakest


I’ve never seen this level before. Is this a new release?


Nope, its a desert level, a pretty old one


Okay cuz I’ve never seen the level in the desert before. When I go to desert it never had an arrow pointing at the level until now.

I thought I finished all non-subscriber code combat levels, until today oof


RU a sub or not? Just curious. :wink:


No I’m not a sub :C

Yeah I know it’s sad. But subscribing wouldn’t let me learn new concepts which is why I didn’t subscribe