Kithgard’s Dungeon - the final kithmaze

I got stuck at this level where I managed to kill all 3 ogres but ended up stabbed to death by spikes on the wall. I was wondering if anyone know what’s wrong with my code

while True:
    enemy = hero.findNearestEnemy()
    if enemy:

Ok first of all

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

secondly you can delete the else.

Welcome to the forum @yinqii :partying_face: :partying_face:

You don’t need the if, or the else.

The maze consists of only 1 pattern, which is the same all the way to the end. You don’t need 3 hero.attack(enemy)s one is enough. The pattern is right, it’s just the if and else that are wrong.

You can do it with the if, but I did it another way.

@Monsty you do need the if

I did it without the if

@yinqii I’ve tried your code but your hero gets stabbed to death by spikes after he kills 1 ogre.

Yes, like Eric_Tang said, you can delete the else and it should work.

You don’t need the extras though.

You don’t need the if else. The enemy is 100% there so you don’t need to check.

if you did solve it please tick the solution box on the comment which helped you the most