Hello, everyone! Please help me fix my code for the Agrippa Defence level in Python.
I suck at coding so it’s probably a very simple beginner’s mistake I can’t spot.
Here’s what I have so far, copied and pasted -
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 hero.isReady(“cleave”) :
hero.cleave(enemy)
else:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
The error message I’m getting is that the target is null on line 13. I don’t understand this as I clearly put the find nearest enemy prior to it.
Any help is appreciated, I know I’m a bit of a bimbo when it comes to this!