[SOLVED] Yeti Eater Level Help

Hello, this topic is for people who need help with Yeti Eater.

1 Like

Here is my code for the level, I don’t know what is up:

# Defeat them in the order from weakest to the strongest.

# The wizard sorted enemies, but in the order from the strongest to the weakest.
wizard = hero.findNearest(hero.findFriends())
yetis = wizard.findEnemies()

# You need iterate the yetis list in the reverse order with a 'for-loop'.
# The start value should be 'len(yetis) - 1'.
# Iterate while the index greater than -1.
# Use the negative step -1.
yetiIndex = len(yetis) - 1
for yeti in yetis:
    # Attack each enemy while its health greater than 0.
    while yeti.health > 0:
        hero.attack(yeti)
    
    yetiIndex -= 1

Can anyone help?

1 Like

I don’t understand how to tell the wizard to spell which Yeti.

1 Like

Actually, you are pretty close. However, instead of using a ‘for’ loop, try using a ‘while’…you are decrementing ‘yetiIndex’ for a reason, after all.

Using the ‘for’ method will simply cycle through the ‘yetis’ array, from start to end; this is the reverse of what is needed. Using ‘while’, with the decreasing ‘yetIndex’ will let you begin at the end and move towards the start.

1 Like

I wouldn’t quite go that far.
Just keep the number of posts down to help us read and understand what you’re saying.
Thanks
Danny

1 Like

Nah that’s fine. You seem to be confusing what “spam” actually is. When they post consecutive posts that is relevant to the current discussion, it’s fine by the means of keeping “threads clean”. When consecutive posts become irrelevant, then it can be considered spam. Next time, please flag the post instead of publicly stating something to avoid the spread of misinformation in case something is borderline.
Thanks.

1 Like

@Apple_314159 do you still need help at the level? If so, can you send me your recent code? (PS I am back)

Andrei

OK, will do next time, sorry.

1 Like

I have just finished the level! Thank you, @dedreous the while loop worked. However, It said that there was an error with the yeti.health even though I defined yeti as yeti = yetis[yetiIndex] the line above. Even so, I still succeeded.

2 Likes