[Solved] What's wrong with my code? Python


#1
while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        if hero.isReady("cleave"):
            hero.cleave()
        else:
            hero.attack()
            hero.shield()
            hero.attack()
        pass
    pass

I really don’t know what’s wrong. The error message I get says “Attack’s argument target should have type object, but got null. Target is null. Is there always a target to attack? (Use if)”

This is on the Kithgard Brawl.


#2

hero.attack needs to attack something. The proper way would be to write: hero.attack(enemy) in this case


#3

Thanks! _________________________