Sarven Brawl 4 help! {Python}

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

# 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:

# 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 :smiley: :sunglasses:

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

I did! see? come on!

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

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

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

Try to add else:

pass

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


there! Don’t tell me to buy something, because I am so close to buying the Order of the Paladin and I want it!

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

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

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

doesn’t work though. :frowning:

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

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

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

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

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

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

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

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

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