I'm in level 17 and I can't for the life of me solve it!

I tries using this code, but before it can even start, a pop-up thing says “Cannot read property ´start´ of undefined”. I dunno what to do I; I tried changing everything, but nothing seems to work.

while True:
    hero.moveRight()
    hero.moveUp()
    enemy = hero.findNearestEnemy()
    hero.attack(enemy)
    hero.attack(hero.findNearestEnemy()
    hero.moveRight()
    hero.moveDown(2)
    hero.moveUp()
1 Like

what level is this(the name)? and you should check if the enemy exists before attacking.

Start getting in the habit now. You have to check if an enemy exists before you can attack it because if there is not an enemy present - even for one second - the code fails. It fails because you are instructing it to do something with an object that isn’t there. This is true for all objects (coins, potions, enemies, mushrooms, etc.).

Yeah, I had a lot of problems with the enemy existing, but now I’ve solved that. Thans for your help, I’ve finished the level!