Siege Of StoneHold

Hey everyone, I’m new here and to coding, I’m trying to figure out if something is wrong with my code.

loop:
    enemy = self.findNearestEnemy()
    flag = self.findFlag()
    if enemy:
        distance = self.distanceTo(enemy)
    if distance < 10:
        if self.isReady("cleave"):
            self.cleave(enemy)
    elif enemy:
        self.attack(enemy)
    elif flag:
        self.pickUpFlag(flag)

I’m not getting any errors, but after he cleaves, he’ll only attack once, and then just stands there until cleave is ready again. How can I make it so he will attack more than once?

My Syntax is correct also, but not sure how to get it to show here.

put on a line by itself both before and after your code paste … three of these characters `

Indentations, they will save your life!

Wait, I just had a Déjà vu.
I’m not gonna write it all again, but your problem is explained quite detailed (excuse the self-advertising) in the linked post.

http://discourse.codecombat.com/t/having-trouble-with-agrippa-defense/2506/27?u=j_f_b_m

Dont worry Deja-vu happens all the time.