Issue with Peasant Protection


I recently tried to rebeat Peasant Protection, and even after following the instructions I had trouble.
Here is my code:

while True:
    enemy = hero.findNearestEnemy()
    distance = hero.distanceTo(enemy)
    if distance < 10:
        # Attack if they get too close to the peasant.
    # Else, stay close to the peasant! Use else.
        self.moveXY(40, 37)

as you can see, I did what the instructions said, but no matter what i did my code didn’t seem to work. the hints didn’t help either.


Do you get some errors? Could you explain "doesn’t work?


@Autri_Basu what kind of sword are you using? I used your code and won the level using the long sword so I am not sure what is happening on your end. Are you using a warrior class to play?

Make sure you can defeat each munchkin with 1 attack and try resubmitting.