# Пустыня сарвена. Пастух сарвена

**URL:** <https://discourse.codecombat.com/t/topic/26257>\
**Category:** русский (Russian)\
**Created:** [December 24, 2020, 4:35pm UTC](https://discourse.codecombat.com/t/topic/26257 "2020-12-24T16:35:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![11180](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/11180/32/15793_2.png) [@11180](https://discourse.codecombat.com/u/11180)\
**Post date:** [December 24, 2020, 4:35pm UTC](https://discourse.codecombat.com/t/topic/26257/1 "2020-12-24T16:35:42Z")

</div>

`Помогите решить задачу. Где и в чем моя ошибка.  
[https://codecombat.com/play/level/sarven-shepherd](https://codecombat.com/play/level/sarven-shepherd)?  
``

# Используй цикл `while`, чтобы выбрать огра

while True:  
enemies = hero.findEnemies()  
enemyIndex = 0

```
# Расположи это в цикле `while`, чтобы атаковать всех врагов.
# Найди длину массива: len(enemies)

```

while enemyIndex \< len(enemies):  
enemy = enemies[enemyIndex]

```
# "!=" значит "не равно".
if enemy.type != "sand-yak":
    enemyIndex += 1
# Пока здоровье врага больше 0, атакуй!
if enemy.health > 0:
    hero.attack(enemy)
    pass

# В перерывах между волнами возвращайся в центр.
hero.moveXY(30, 30)    

```

```python

```

---

<div class="post-metadata">

**Author:** ![PeterPalov](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/peterpalov/32/45280_2.png) [@PeterPalov](https://discourse.codecombat.com/u/PeterPalov)\
**Post date:** [December 25, 2020, 10:17am UTC](https://discourse.codecombat.com/t/topic/26257/2 "2020-12-25T10:17:12Z")

</div>

> [@11180](#):
>
> ```python
> # "!=" значит "не равно".
> if enemy.type != "sand-yak":
> enemyIndex += 1
> # Пока здоровье врага больше 0, атакуй!
> if enemy.health > 0:
> hero.attack(enemy)
> pass
> 
> ```

Мне кажется проблема здесь.

1. Нужно написать вместо if, While True. (вот здесь: if enemy.health \> 0:  
hero.attack(enemy)  
pass)
2. Это while true нужно поставить в if enemy.type != “sand-yak”:  
enemyIndex += 1

А так вроде все правильно.
