Hello, this topic is for people who need help with Yeti Eater.
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?
I donât understand how to tell the wizard to spell which Yeti.
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.
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
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.
@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.
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.