Mad maxer python

Its saying please double check your code carefully unexpected token

enemyIndex = 0
enemies = self.findEnemies()

# Look at all the enemies to figure out which one is farthest away.
while enemyIndex < len(enemies):
    target = enemies[enemyIndex]
    enemyIndex += 1
  # Is this enemy farther than the farthest we've seen so far?
    distance = self.distanceTo(target)
    if distance > maxDistance:
        maxDistance = distance
        farthest = target

if farthest:
    # Take out the farthest enemy!
    # Keep attacking the enemy while its health is greater than 0.
    pass
    while farthest.health > 0:
    if self.isReady("power-up"):
        self.powerUp()
    else:
        self.attack(farthest)

this is my new code but my hero wont attack he just runs away

#Kill the enemy that's farthest away first.
loop:
    farthest = None
    maxDistance = 0
    enemyIndex = 0
    enemies = self.findEnemies()

# Look at all the enemies to figure out which one is farthest away.
while enemyIndex < len(enemies):
    target = enemies[enemyIndex]
    enemyIndex += 1
  # Is this enemy farther than the farthest we've seen so far?
    distance = self.distanceTo(target)
    if distance > maxDistance:
        maxDistance = distance
        farthest = target

if farthest:
    # Take out the farthest enemy!
    # Keep attacking the enemy while its health is greater than 0.
    pass
    while farthest.health > 0:
           if self.isReady("power-up"):
                         self.powerUp()
else:
        self.attack(farthest)

try putting your while loop inside the actual loop