i’m having a lot of trouble with levels that uses enemy.health or coin.value, Can someone please explain why this is happening?
# 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! hero.attack(weakestShaman)