Munchkin swarm! i cant win!

i cannot beat this level. i use Python and my hero is Anya. please post your code and how it worked for you

this is the code i used

while True:

distance = hero.distanceTo(target)
hero.cleave(enemy)
else:
    hero.attack("Chest")

What you have so far is correct, but you are missing a few things.

You start your code with:

distance = hero.distanceTo(target)

but you never told your code what ‘target’ means, so your code doesn’t know what you mean with that word. You need to define that first.

Then, on the next line, you want to cleave an enemy, but once again, you haven’t defined what an enemy is. (also, why do you call it target first, and enemy later? Choose one and stick with it),

Then all of a sudden you have “else:” but how can it decide what this “else:” means if you did not define an if statement?

And finally, is cleave always ready? What happens when there are enemies, but cleave is not ready? Will you just stand around and wait for cleave to be ready again?

Thank you for the help! im still having a little bit of trouble though. here is my updated code.

target = "munchkin"
while True:
if “munchkin”:
distance = hero.distanceTo(target)
ready = hero.isReady(“cleave”)

else:
    hero.attack("chest")

You should go back to a previous level and look at how you defined an enemy (or target) in other levels.

Also, indentation is important for block coding.

I BEAT THE LEVEL!!! YESSS!!!:grinning::grinning::grin:

It takes practice, but you can do it!

1 Like