Need assistance


#1

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.


#2

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)

#3

Thanks for the help!


#4

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


#5

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


#6

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