Just started working on this level again. First started it back in July and still can’t figure out what the heck is wrong. Everything I do just produces more bright red errors that don’t make any sense to me.
I have no idea what this error means. Any help is appreciated. I’ve really been struggling with this for a while. Thanks.
This is my current code. It still produces the same error as in above screenshot.
def sumHealth(enemies): # Create a variable and set it to 0 to start the sum. totalHealth = 0 enemyIndex = 0 # Initialize the loop index to 0 while enemyIndex < len(enemies): # While index is less than the length of enemies array enemy = enemies[enemyIndex] if enemy and enemy.health > 0: enemy.health += enemies[totalHealth] # Add the current enemy's health to totalHealth enemyIndex += 1 # Increment the index. return totalHealth # Use the cannon to defeat the ogres. cannon = hero.findNearest(hero.findFriends()) # The cannon can see through the walls. enemies = cannon.findEnemies() # Calculate the sum of the ogres' health. ogreSummaryHealth = sumHealth(enemies) hero.say("Use " + ogreSummaryHealth + " grams.")