The Agrippa Defense: Code Doesn't Work


#1

I have been stuck on this level for several days. I have even visited several of the tutorials on YouTube, and their code is exactly the same. Except, their code worked, and mine doesn’t. Can someone help me please? This is what my code looks like:

while True:
enemy = hero.findNearestEnemy()
if enemy:
pass # Replace this with your own code.
# Find the distance to the enemy with distanceTo.
distance = hero.distanceTo(enemy)
# If the distance is less than 5 meters…
if distance < 5:
# … if “cleave” is ready, cleave!
if hero.isReady(“cleave”):
hero.cleave(enemy)
# … else, just attack.
else:
hero.attack(enemy)

this is the link to the video that has the same code as me:

-Aubrey.


#2

@Aubrey_Lynn The code seems to work for me. Can you use the code formatter to show us the tabs on the code. In python if the tab spacing is off it will cause different things to happen.

Click on the "Preformatted text button after highlighting your code: