Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

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


@Chaboi_3000 indentation doesn’t matter… i had extra indentation before and the level still worked.
Less than necessary indentation is bad though.
I think the problem is this:
after the if section loop:
you need to add an else statement and put the moveXY inside it
like this:

    hero.moveXY(x, y) <-- put coords in

Or put the hero.moveXY(x,y) code in the if statement.


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):
index+=1 (这里是让Index自增而遍历所有对象)
所以 通关代码应该是这样:
while True:
while enemyIndex < len(enemies):




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


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


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

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

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?


my english is not too i no to test it.:sweat_smile:


有两种办法 一种是直接用hero.findNearestEnemy()方法 另外一种是用hero.findNearest(hero.findEnemies()) 没记错的话 第二种是老版本使用的