# 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.
for yeti.health > 0:
hero.attack(yeti)
yetiIndex -= 1
the error is on this line:
for yeti.health > 0:
and the error says: “there is a problem with your code” and thats all it says plz hlp
# 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.
for i in range(len(yetis) - 1, -1, -1):
while yetis[i].health > 0:
hero.attack(yeti [i])
yetiIndex -= 1
# 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.
# Attack each enemy while its health greater than 0.
for i in range(len(yetis) - 1, -1, -1):
while yetis[i].health > 0:
hero.attack("yeti [i]")
Look closer at the array in what the yeties are hold in. Do you see anything wrong with the array that you are using to attack? I said that you do not need “” when you are using variables, you only use them when you target enemies by their name as you did in the dungeon.