I post to many topics. Weakest Quickest help please! [Solved]

Lol, I love it when that happens :laughing:. Ok let’s fix that. Will you post your current code?

def findWeakestEnemy():
    enemies = hero.findEnemies()
    enemyIndex = 0
    weakest = None
    leastHealth = 99999
    while enemyIndex < len(enemies):
        enemy = enemies[enemyIndex]
        if enemy.health < leastHealth:
            weakest = enemy
            leastHealth = enemy.health
    return weakest

while True:
    enemy = findWeakestEnemy()
    if enemy:
        hero.attack(enemy)

Oh wait. don’t look at that one

1 Like

I know why enemy doesn’t work.

Hmmm…what if you try entirely taking that line out?

enemies = hero.findEnemies()

And like I said, keep this as it was first. Below the 9999

it is because it is singular instead of plural. Being singular means it would be the weakest either way so you just end up attacking whatever one enemy it chooses instead of the weakest.

Uhhhh. that didn’t work either. :weary:

1 Like

…is this a sub level?

Yah. In Desert. Desert is bugging me. I just cant wait for glacier…

1 Like

Oh. I’m not a sub, so I can’t see my level. Plus, trying to see CoCo on a phone isn’t helping either. Unless i can get on a computer, you’re going to have to wait, sorry.

That is fine. I can wait.

1 Like

Thx though for trying.

1 Like

I looked it up on GitHub. I changed my answer to match exactly. It doesn’t work.

Wait a sec. Am I supposed to do
blank += 1

Alejandro’s name. Kinda funny

after that I broke it

You’re not supposed to copy and paste since that’s cheating and you’re not learning anything.

I didn’t copy in paste. I just compared them. I kinda just gave up.