# 請教 不知道哪裏錯了？就是不運行

not move:rofl:

not move

hit backspace once before the `else:`
actually, lemme just type up the level and paste in your code and edit it.
This is way to frustrating

1 Like

ok i got it fixed. I’ll message you the solution, since this is an easy level, and you have shown your efforts. @Chaboi_3000 am i allowed to share the solution?

1 Like

No(must 20 characters)

1 Like

I can not think of any other way to finish this level.

@Chaboi_3000 we’re literally telling him what changes to make in his code so he can pass the level though… what’s the difference?

while循环代替for循环时，由于for循环是遍历所有的对象的（无论对不对这个对象做什么事情），所以，while循环里的index属性也得遍历所有的对象 就像这样：
while(index < length):
somestatements
index+=1 (这里是让Index自增而遍历所有对象)

while True:
(定义enemies与enemyIndex)
while enemyIndex < len(enemies):
(定义enemy并攻击)
enemyIndex+=1
pass
(移动回中央)

Step by step really teaches while giving the code out will be the same as cheating.

fine… but we gotta teach him why to do this or that though… and we didn’t… and life’s hard

Can you post your code here so I can copy and paste in and see whats wrong? There I can help.

while True:
enemies = hero.findEnemies()
enemyIndex = 0
# 将攻击逻辑放到 while 循环里来攻击所有的敌人。
# Find the array’s length with: len(enemies)
if enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
# “!=” 意思是 "不等于"
if enemy.type != “sand-yak”:
# 当敌人的健康值大于0，攻击它！
if enemy.health > 0:
hero.attack(enemy)
else:
hero.moveXY(42,32)
pass

``    # 在两波敌人之间，移动回中央。``

I accept"step by step".but how to "step by step"
So far ,I still don’t understand why hero doesn’t move?

Can you format your code according to the FAQ?

discourse.codecombat.com/faq

my english is not too good.so i no to test it.