When i run my code it shows this error.
def findWeakestEnemy():
enemies = hero.findEnemies()
weakest = None
leastHealth = 99999
enemyIndex = 0
# Loop through enemies:
while enemyIndex < len(enemies):
# If an enemy's health is less than leastHealth:
enemy = enemies[enemyIndex]
if enemy.health < leastHealth:
# Make it the weakest
enemy[enemyIndex] = weakest
# and set leastHealth to its health.
leastHealth = enemy[enemyIndex].health
pass
enemyIndex += 1
pass
return weakest
while True:
# Find the weakest enemy with the function:
findWeakestEnemy()
# If the weakest enemy here:
if weakest:
# Attack it!
hero.attack(weakest)
pass