Lurkers! Request for help请求帮助

这一关,完全没明白意思!!!
this is my code,Where do errors?

# 用findEnemies把敌人存在数组enemies中
# 只攻击萨满巫师,不要攻击牦牛!

enemies = self.findEnemies()
enemyIndex = 0

# 把这段代码用一个while loop 功能循环遍历所有的敌人
while enemyIndex < len(enemies):
    enemy = enemies[enemyIndex]
    if enemy.type == 'shaman':
        while enemy.health > 0:
            self.attack(enemy)
            enemyIndex += 1

(Sorry, english help only from me)

You increase enemyIndex only when you found a shaman. You have to increase it everytime.

enemies = self.findEnemies()
enemyIndex = 0

while enemyIndex < len(enemies):
    enemy = enemies[enemyIndex]
    enemyIndex += 1              # Increase enemyIndex even if enemy is not a shaman
    if enemy.type == 'shaman':
        while enemy.health > 0:
            self.attack(enemy)
1 Like

thank you!我发现了自己错在何处!:没装备攻击型武器!!!!I found a mistake, I did not assault weapons and equipment

谢谢你的提醒,enemyindex赋值在while后面。已经完成此关,但有错误提示如下:‘enemy’ was null. Use a null check before accessing properties. Try

Thank you for reminding me, enemyindex assignment in the back while. Have already done this off, but there is an error message as follows:‘enemy’ was null. Use a null check before accessing properties. Try