Need assistance

I was playing the munchkin swarm level in python and it kept on telling me I need to indent my if statement, even after I had already done so.
My code looked something like this:

enemy = self.findNearestEnemy()
    if enemy > 10:
        self.attack("Chest")
    if enemy < 10:
        self.cleave(enemy)

and the same message saying “Code needs to line up, improper indent” appears every time.

Since enemy is an object, Objects can not be compared with number,Need to get the distance to the object, e.g.

loop:
    enemy=self.findNearestEnemy()
    distance=self.distanceTo(enemy)
    if distance>10:
        self.moveXY(46, 40)
        self.attack("Chest")
    else:
        if self.isReady("cleave"):
            self.cleave(enemy)
        else:
            self.attack(enemy)

Thanks for the help!

I have tried your code,but told “Line5:undefined is not a function”.And why?

Do you have the second pair of glasses (not the Crude Glasses but the Wooden Glasses) equipped?

No,and i tried again with wooden glasses.it worked,thank you very much!