# Sarven Brawl 4 help! {Python}

**URL:** <https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359>\
**Category:** Level Help\
**Created:** [November 12, 2020, 8:49pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359 "2020-11-12T20:49:17Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![The\_Master\_Coder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/the_master_coder/32/32336_2.png) [@The\_Master\_Coder](https://discourse.codecombat.com/u/The_Master_Coder)\
**Post date:** [November 12, 2020, 8:49pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/1 "2020-11-12T20:49:17Z")

</div>

Hey guys! I need help with Sarven Brawl and I will explain everything here. First, the code:

```python
# Stay alive for two minutes.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Remember, each submission gets a new random seed.

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

```

Now that I got the code, I will explain. First, don’t expect me to know everything about Python because I am just a KID. Ok problem:  
I am specifically telling the code to attack enemies and it is just doing that. But it attacks SAND YAKS and I don’t want that to happen so I updated my code:

```python
# Stay alive for two minutes.
# If you win, it gets harder (and more rewarding).
# If you lose, you must wait a day before you can resubmit.
# Remember, each submission gets a new random seed.

while True:
    enemy = hero.findNearestEnemy()
    if enemy.type != "sand-yak":
        hero.attack(enemy)

```

And it is counting the sand yak as the enemy and my hero is not attacking the ogres. Please help!  
By the way, I am not a subscriber and I am only 8. Hero: Sir Thatrin Thunderfirst (I just love his fierce look!) So…Please help! @Deadpool198? @AnSeDra? Guys, help! Anyway, you can just call me Surya Raghavan because that is my real name (first and last) Don’t think that I am just in Sarven Desert because I finished the whole game 😃 🕶

---

<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 12, 2020, 9:06pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/2 "2020-11-12T21:06:18Z")

</div>

You have to check if there is an enemy first.  
Lydia

---

<div class="post-metadata">

**Author:** ![The\_Master\_Coder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/the_master_coder/32/32336_2.png) [@The\_Master\_Coder](https://discourse.codecombat.com/u/The_Master_Coder)\
**Post date:** [November 12, 2020, 9:06pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/3 "2020-11-12T21:06:57Z")

</div>

I did! see? come on!

---

<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 12, 2020, 9:10pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/4 "2020-11-12T21:10:28Z")

</div>

Ok, so these two codes do very different things, which code do you need to work on?  
Lydia

---

<div class="post-metadata">

**Author:** ![The\_Master\_Coder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/the_master_coder/32/32336_2.png) [@The\_Master\_Coder](https://discourse.codecombat.com/u/The_Master_Coder)\
**Post date:** [November 12, 2020, 9:12pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/5 "2020-11-12T21:12:25Z")

</div>

the second one. Or you can look at the problem I stated earlier

---

<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 12, 2020, 9:19pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/6 "2020-11-12T21:19:30Z")

</div>

This probably won’t do anything but can you send a screen shot of your equipment

---

<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 12, 2020, 9:21pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/7 "2020-11-12T21:21:10Z")

</div>

Try to add `else:`

`pass`

---

<div class="post-metadata">

**Author:** ![The\_Master\_Coder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/the_master_coder/32/32336_2.png) [@The\_Master\_Coder](https://discourse.codecombat.com/u/The_Master_Coder)\
**Post date:** [November 12, 2020, 9:22pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/8 "2020-11-12T21:22:23Z")

</div>

wait! Don’t go one yet! Here is the screen shot:

 ![Screenshot 2020-11-12 at 4.21.32 PM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/6/c/6cddd3e560da67976c6b047d588a56e47c7f174d.jpeg)  
there! Don’t tell me to buy something, because I am so close to buying the Order of the Paladin and I want it!

---

<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 12, 2020, 9:25pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/9 "2020-11-12T21:25:54Z")

</div>

I’m confused what do you mean "Don’t go one yet!’

---

<div class="post-metadata">

**Author:** ![The\_Master\_Coder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/the_master_coder/32/32336_2.png) [@The\_Master\_Coder](https://discourse.codecombat.com/u/The_Master_Coder)\
**Post date:** [November 12, 2020, 9:26pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/10 "2020-11-12T21:26:27Z")

</div>

I meant Don’t go further yet! and here is the updated code:

```python
while True:
    enemy = hero.findNearestEnemy()
    if enemy.type != "sand-yak":
        hero.attack(enemy)
    else:
        pass

```

---

<div class="post-metadata">

**Author:** ![The\_Master\_Coder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/the_master_coder/32/32336_2.png) [@The\_Master\_Coder](https://discourse.codecombat.com/u/The_Master_Coder)\
**Post date:** [November 12, 2020, 9:27pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/11 "2020-11-12T21:27:03Z")

</div>

doesn’t work though. ☹

---

<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 12, 2020, 9:27pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/12 "2020-11-12T21:27:46Z")

</div>

I got a few sugestions  
first maybe try to use the invisibility ring  
second do if your health is lower than 200 than sheild

---

<div class="post-metadata">

**Author:** ![The\_Master\_Coder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/the_master_coder/32/32336_2.png) [@The\_Master\_Coder](https://discourse.codecombat.com/u/The_Master_Coder)\
**Post date:** [November 12, 2020, 9:28pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/13 "2020-11-12T21:28:59Z")

</div>

do I need to buy anything? cause I don’t want to. I am saving up to buy “Order of the Paladin”.

---

<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 12, 2020, 9:29pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/14 "2020-11-12T21:29:23Z")

</div>

No you do not. You have both the things I stated

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [November 12, 2020, 9:31pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/15 "2020-11-12T21:31:27Z")

</div>

What happens now, does your hero actually attack ogres even if there is a yak?

---

<div class="post-metadata">

**Author:** ![The\_Master\_Coder](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/the_master_coder/32/32336_2.png) [@The\_Master\_Coder](https://discourse.codecombat.com/u/The_Master_Coder)\
**Post date:** [November 12, 2020, 9:31pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/16 "2020-11-12T21:31:32Z")

</div>

I do! okay. It’s called “The precious” actually

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [November 12, 2020, 9:33pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/17 "2020-11-12T21:33:15Z")

</div>

You should use flags to move around, so that you can retreat to places.

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [November 12, 2020, 9:49pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/18 "2020-11-12T21:49:04Z")

</div>

but if he fails using flags then he will have to wait a day to re-submit. So that is not a good option

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [November 12, 2020, 9:50pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/19 "2020-11-12T21:50:04Z")

</div>

Try getting success without using flags, but incorporating them into the code, then use flags in the actual level after success on the run.

---

<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 12, 2020, 10:13pm UTC](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359/20 "2020-11-12T22:13:36Z")

</div>

Like I said, you need to check if there is an enemy _ **first** _  
Lydia

[Next page](https://discourse.codecombat.com/t/sarven-brawl-4-help-python/25359.md?page=2)
