# Kithgard’s Dungeon - the final kithmaze

**URL:** <https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673>\
**Category:** Level Help\
**Created:** [November 26, 2020, 2:36am UTC](https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673 "2020-11-26T02:36:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![yinqii](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/yinqii/32/16807_2.png) [@yinqii](https://discourse.codecombat.com/u/yinqii)\
**Post date:** [November 26, 2020, 2:36am UTC](https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673/1 "2020-11-26T02:36:37Z")

</div>

Hello!  
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

```python
while True:
    enemy = hero.findNearestEnemy()
    
    if enemy:
        hero.attack(enemy)
        hero.attack(enemy)
        hero.attack(enemy)
    
    else:
        
        hero.moveRight()
        hero.moveUp()
        hero.moveRight()
        hero.moveDown(2)
        hero.moveUp() 

```

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [November 26, 2020, 2:41am UTC](https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673/2 "2020-11-26T02:41:08Z")

</div>

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](https://discourse.codecombat.com/t/welcome-to-codecombat-discourse-forums/15601), which shows all essentials of this board! Thanks!

secondly you can delete the else.

---

<div class="post-metadata">

**Author:** ![Monsty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/monsty/32/20923_2.png) [@Monsty](https://discourse.codecombat.com/u/Monsty)\
**Post date:** [November 26, 2020, 3:09am UTC](https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673/3 "2020-11-26T03:09:25Z")

</div>

Welcome to the forum @yinqii 🥳 🥳

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.

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [November 26, 2020, 3:10am UTC](https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673/4 "2020-11-26T03:10:10Z")

</div>

@Monsty you do need the if

---

<div class="post-metadata">

**Author:** ![Monsty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/monsty/32/20923_2.png) [@Monsty](https://discourse.codecombat.com/u/Monsty)\
**Post date:** [November 26, 2020, 3:12am UTC](https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673/5 "2020-11-26T03:12:21Z")

</div>

I did it without the if

---

<div class="post-metadata">

**Author:** ![Monsty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/monsty/32/20923_2.png) [@Monsty](https://discourse.codecombat.com/u/Monsty)\
**Post date:** [November 26, 2020, 3:17am UTC](https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673/6 "2020-11-26T03:17:58Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [November 26, 2020, 3:31am UTC](https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673/8 "2020-11-26T03:31:54Z")

</div>

Yes, like Eric\_Tang said, you can delete the else and it should work.  
Lydia

---

<div class="post-metadata">

**Author:** ![Monsty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/monsty/32/20923_2.png) [@Monsty](https://discourse.codecombat.com/u/Monsty)\
**Post date:** [November 26, 2020, 3:43am UTC](https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673/9 "2020-11-26T03:43:23Z")

</div>

> [@yinqii](#):
>
> ```python
> hero.attack(enemy)
> hero.attack(enemy)
> 
> ```

You don’t need the extras though.

---

<div class="post-metadata">

**Author:** ![Code\_Master](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_master/32/16184_2.png) [@Code\_Master](https://discourse.codecombat.com/u/Code_Master)\
**Post date:** [November 26, 2020, 5:41am UTC](https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673/10 "2020-11-26T05:41:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ineedhelpwithcoding](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ineedhelpwithcoding/32/30168_2.png) [@ineedhelpwithcoding](https://discourse.codecombat.com/u/ineedhelpwithcoding)\
**Post date:** [November 27, 2020, 6:19am UTC](https://discourse.codecombat.com/t/kithgard-s-dungeon-the-final-kithmaze/25673/11 "2020-11-27T06:19:04Z")

</div>

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