Keeping Time; enemy is not defined, help!

Okay, so I think the coding is good, but it keeps showing this message:

This is my code:

loop:
    # If it's the first 10 seconds, fight.
    enemy = self.findEnemies()
    if self.now() < 10:
        if enemy:
            if self.isReady("cleave"):
                self.cleave(enemy)
            else:
                self.attack(enemy)
        

    else:
        if self.now() < 30:
            items = self.findItems()
            x = item.pos.x
            y = item.pos.y
            self.moveXY(x, y)
        if self.now() > 30:
            if enemy:
                if self.isReady("cleave"):
                    self.cleave(enemy)
                else:
                    self.attack(enemy)
        
    # Else, if it's the first 30 seconds, collect coins.
    # After 30 seconds, join the raid!

Thanks!

Self.findEnemies returns a list. You can’t attack a list (Well, you can, but not in a programming sense). You need to use self.findNearest first.

Okay thanks, I couldn’t figure out what was wrong with it…
:relaxed:

Mod Edit: Please don’t swear

It so isn’t! Codecombat is boss.