# The Mighty Sand Yak Help (Python) (SOLVED)

**URL:** <https://discourse.codecombat.com/t/the-mighty-sand-yak-help-python-solved/30967>\
**Category:** Level Help\
**Created:** [October 14, 2021, 12:46pm UTC](https://discourse.codecombat.com/t/the-mighty-sand-yak-help-python-solved/30967 "2021-10-14T12:46:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![loklok2013](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@loklok2013](https://discourse.codecombat.com/u/loklok2013)\
**Post date:** [October 14, 2021, 12:46pm UTC](https://discourse.codecombat.com/t/the-mighty-sand-yak-help-python-solved/30967/1 "2021-10-14T12:46:22Z")

</div>

I don’t know how to do it

---

<div class="post-metadata">

**Author:** ![MarcusL123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/marcusl123/32/23238_2.png) [@MarcusL123](https://discourse.codecombat.com/u/MarcusL123)\
**Post date:** [October 14, 2021, 12:47pm UTC](https://discourse.codecombat.com/t/the-mighty-sand-yak-help-python-solved/30967/2 "2021-10-14T12:47:15Z")

</div>

Can you send your code here? Or do you have no code?

---

<div class="post-metadata">

**Author:** ![loklok2013](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@loklok2013](https://discourse.codecombat.com/u/loklok2013)\
**Post date:** [October 14, 2021, 12:47pm UTC](https://discourse.codecombat.com/t/the-mighty-sand-yak-help-python-solved/30967/3 "2021-10-14T12:47:55Z")

</div>

# Let yaks get close, then move 10m right to dodge.

# Dodge 4 yaks to complete the level.

while True:  
# Get hero’s current x and y position.  
x = hero.pos.x  
y = hero.pos.y

```
# Find the nearest yak.
yak = hero.findNearestEnemy()

# If the distanceTo the yak is less than 10:
if hero.distanceTo(yak) < 10:
    # To move right, add 10 to hero's x position.
    hero.moveXY(+ 10)
    # Use moveXY(x, y) to move!
    
    pass

```

---

<div class="post-metadata">

**Author:** ![MarcusL123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/marcusl123/32/23238_2.png) [@MarcusL123](https://discourse.codecombat.com/u/MarcusL123)\
**Post date:** [October 14, 2021, 12:51pm UTC](https://discourse.codecombat.com/t/the-mighty-sand-yak-help-python-solved/30967/4 "2021-10-14T12:51:27Z")

</div>

Tips:

1. hero.moveXY() needs 2 parameters, you need to be`hero.moveXY(hero.pos.x, hero.pos.y +` number

2.

---

<div class="post-metadata">

**Author:** ![Vanessa](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vanessa/32/33899_2.png) [@Vanessa](https://discourse.codecombat.com/u/Vanessa)\
**Post date:** [October 14, 2021, 1:14pm UTC](https://discourse.codecombat.com/t/the-mighty-sand-yak-help-python-solved/30967/5 "2021-10-14T13:14:26Z")

</div>

I don’t know python much, but I think you should put the x and the y in the `hero.moveXY`

> **Hint**
>
> ```python
> hero.moveXY(x + 10, y)
> 
> ```

---

<div class="post-metadata">

**Author:** ![loklok2013](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@loklok2013](https://discourse.codecombat.com/u/loklok2013)\
**Post date:** [October 14, 2021, 1:14pm UTC](https://discourse.codecombat.com/t/the-mighty-sand-yak-help-python-solved/30967/6 "2021-10-14T13:14:34Z")

</div>

I didi the Mighty Sand Yak

---

<div class="post-metadata">

**Author:** ![loklok2013](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@loklok2013](https://discourse.codecombat.com/u/loklok2013)\
**Post date:** [October 14, 2021, 1:15pm UTC](https://discourse.codecombat.com/t/the-mighty-sand-yak-help-python-solved/30967/7 "2021-10-14T13:15:06Z")

</div>

Need code for that level?

---

<div class="post-metadata">

**Author:** ![Vanessa](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vanessa/32/33899_2.png) [@Vanessa](https://discourse.codecombat.com/u/Vanessa)\
**Post date:** [October 14, 2021, 1:15pm UTC](https://discourse.codecombat.com/t/the-mighty-sand-yak-help-python-solved/30967/8 "2021-10-14T13:15:35Z")

</div>

No, solutions are not allowed on the discourse so its fine 👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [October 15, 2021, 1:15am UTC](https://discourse.codecombat.com/t/the-mighty-sand-yak-help-python-solved/30967/9 "2021-10-15T01:15:59Z")

</div>

Closed on October 15, 2021, 1:15am UTC

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
