while True:
enemy = hero.findNearestEnemy()
# Put your attack code here
if enemy:
cleaveWhenClose(enemy)
def cleaveWhenClose(target):
# else, just attack `target`!
else:
hero.attack(enemy)
ok
I’m going for lunch be back later
sorry I am trying 20000000
def cleaveWhenClose(target):
if hero.distanceTo(target) < 5:
ready = hero.isReady("cleave")
hero.cleave(target)
else:
hero.attack(target)
while True:
target = hero.findNearestEnemy()
if target:
cleaveWhenClose(target)
This statement is doing nothing for you…all it is doing is defining ‘ready’ as either True or False. What are you doing with it after this?
Instead, it needs to be an ‘if’ statement. Something like:
if hero is ready to cleave, then
cleave
otherwise
attack
For some reason (I passed this level), I have the correct code but it shows me this:

I don’t know why.
Lydia
P.S I’m not gonna post the code because I know its the correct code and I don’t want anyone to cheat off my code.
def cleaveWhenClose(target):
if hero.distanceTo(target) < 5:
pass
# Put your attack code here
# If cleave is ready, then cleave target
if enemy:
ready = hero.isReady("cleave")
hero.cleave(enemy)
# else, just attack `target`!
else:
hero.attack(enemy)
Until you fix this, there is not much we can help you with.
def cleaveWhenClose(target):
if hero.distanceTo(target) < 5:
pass
# Put your attack code here
# If cleave is ready, then cleave target
if enemy:
ready = hero.isReady("cleave")
^
I
Do I get rid of it
# else, just attack `target`!
else:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
hero.attack(enemy)
Refer to my previous post.
Omg finally!!!

thank you !!!
@dedreous & @Jake_Doggy
Welcome and well done!
Congrats!

Can someone help with my problem now?
Lydia
yes what is it?222222
Ok is it the steelclaw gap or something
It is Leave It To The Cleaver. The thing is… I passed this level a long time ago… about 2 months ago. So I don’t really need to solve it, but it’s a bug that I’ve found.
Lydia
ok so do you still need help?
