# Endangered Burl trouble

**URL:** https://discourse.codecombat.com/t/endangered-burl-trouble/2418
**Category:** Adventurer
**Created:** [January 22, 2015, 12:01pm UTC](https://discourse.codecombat.com/t/endangered-burl-trouble/2418 "2015-01-22T12:01:11Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![iloveuganda1996](https://avatars.discourse-cdn.com/v4/letter/i/e68b1a/32.png) [@iloveuganda1996](https://discourse.codecombat.com/u/iloveuganda1996)
#### Post date: [January 22, 2015, 12:01pm UTC](https://discourse.codecombat.com/t/endangered-burl-trouble/2418/1 "2015-01-22T12:01:11Z")

</div>

```python
loop:
    enemy = self.findNearestEnemy()
    
    # Remember: don't attack type "burl"!
    if enemy.type is "burl":
        self.say("I'm not attacking that Burl!")

    # The "type" property tells you what kind of creature it is.
    if enemy.type is "munchkin":
        self.attack(enemy)
        self.attack(enemy)
    # Use "if" to attack a "thrower".
    if enemy.type is "thrower":
        self.attack(enemy)
        self.attack(enemy)
    
    # If it's an "ogre", run away to the village gate!
    if enemy.type is "orge":
        self.moveXY(40, 47)

```

Whats wrong with my code? I have spent a lot of time, trying to figure this out. I have read other forums posts and they do not make sense.

---

<div class="post-metadata">

### Author: ![dwhittaker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dwhittaker/32/2114_2.png) [@dwhittaker](https://discourse.codecombat.com/u/dwhittaker)
#### Post date: [January 22, 2015, 3:05pm UTC](https://discourse.codecombat.com/t/endangered-burl-trouble/2418/2 "2015-01-22T15:05:42Z")

</div>

What is the error that is happening? The code does look pretty good to me… The only possible issue I see is that you are attacking twice for munchkins and throwers. Better would be to only attack once each time through the loop, in case the first attack kills them.

---

<div class="post-metadata">

### Author: ![Yaur](https://avatars.discourse-cdn.com/v4/letter/y/8baadc/32.png) [@Yaur](https://discourse.codecombat.com/u/Yaur)
#### Post date: [January 22, 2015, 4:27pm UTC](https://discourse.codecombat.com/t/endangered-burl-trouble/2418/3 "2015-01-22T16:27:35Z")

</div>

Whats the error? could enemy be `None`?

---

<div class="post-metadata">

### Author: ![nick](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/nick/32/784_2.png) [@nick](https://discourse.codecombat.com/u/nick)
#### Post date: [January 22, 2015, 4:55pm UTC](https://discourse.codecombat.com/t/endangered-burl-trouble/2418/4 "2015-01-22T16:55:01Z")

</div>

Ah, I see it: you have “orge” instead of “ogre”.

---

<div class="post-metadata">

### Author: ![Roberto](https://avatars.discourse-cdn.com/v4/letter/r/8baadc/32.png) [@Roberto](https://discourse.codecombat.com/u/Roberto)
#### Post date: [January 22, 2015, 9:45pm UTC](https://discourse.codecombat.com/t/endangered-burl-trouble/2418/5 "2015-01-22T21:45:00Z")

</div>

Also, remember that not always `self.findNearestEnemy()` will return an enemy (sometimes there isn’t any). In that case your code would fail to find an `enemy.type`.

---

<div class="post-metadata">

### Author: ![Rytrik](https://avatars.discourse-cdn.com/v4/letter/r/3e96dc/32.png) [@Rytrik](https://discourse.codecombat.com/u/Rytrik)
#### Post date: [January 22, 2015, 9:53pm UTC](https://discourse.codecombat.com/t/endangered-burl-trouble/2418/6 "2015-01-22T21:53:38Z")

</div>

@Roberto - The code won’t fail as he has it designed, for this particular level. I just checked the level (and my successful code), and there are always enemy Burl around. However, normally, it is great practice to have `if enemy` before the `enemy.type` checks. I do agree on a general basis.
