Help me on this level please


this level is distraction maneuver.
I can’t find what is wrong
can you help me.
thanks a lot.

def findFurthest(units):
furthestUnit = None
maxDistance = 0
def findFurthest(units):
furthestUnit = None
maxDistance = 0
unitIndex = 0
while unitIndex < len(units):
target = hero.findNearestEnemy()
currentUnit = units[unitIndex]
# Find the distance to currentUnit:
distance = hero.distanceTo(target)
# If that distance greater than maxDistance:
if distance > maxDistance:
# Reassign furthestUnit and maxDistance:
maxDistance = distance
farthest = target
unitIndex += 1
return furthestUnit

It’s like findNearestEnemy but vice versus.

def findFurthestEnemy():
enemies = hero.findEnemies()
furthestEnemy = findFurthest(enemies)
# Return furthestEnemy:
return futhestUnit

The function makes the hero attack without distractions.

def attackWhileAlive(target):

# Attack target while it's health > 0:
while > 0:

while True:
# To protect peasants, hunt for furthest ogres.
furthestOgre = findFurthestEnemy()
if furthestOgre:


Can you please format your whole code according to the FAQ?
Also a couple of questions:
-Does the level display any error messages (for example "thang is undefined", etc.), or is your code just not beating the level?
-What does your hero do? Does your hero just stand there, or do something weird, or just run out of health?

Be sure to define furthestUnit. You are defining it as farthest, so that causes an error.
You define currentUnit = units[unitIndex], but you do not use the variable currentUnit and instead use target. target is an undefined variable, which also causes an error.


FAQ is the </> button above where you type on the same bar of the emoji click it and just past your code.