# \[SOLVED\] Python code error on Thunderhooves

**URL:** <https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600>\
**Category:** Level Help\
**Created:** [November 12, 2019, 6:25am UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600 "2019-11-12T06:25:13Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![shicheng09](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@shicheng09](https://discourse.codecombat.com/u/shicheng09)\
**Post date:** [November 12, 2019, 6:25am UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/1 "2019-11-12T06:25:13Z")

</div>

Hi there I got a code error stucking few days on Thunderhooves

My code is like:  
while True:  
yak = hero.findNearestEnemy()  
if yak:  
# If yak.pos.y is greater than hero.pos.y  
if yak.pos.y \> hero.pos.y:  
# buildXY a “fence” 10m below the yak.  
hero.buildXY(“fence”, yak.pos.x, yak.pos.y - 10)  
else:  
# buildXY a “fence” 10m above the yak.  
hero.buildXY(“fence”, yak.pos.x, yak.pos.y + 10)  
pass  
else:  
# moveXY right 10m towards the oasis.  
hero.moveXY(hero.pos.x + 10, hero.pos.y)  
pass

I got the python error code:

Line 11: ArgumentError:build’s argument toBuild should have type object, but got string:“fence”. You need a string to build; one of [“bear-trap”]

Any advice for this? Thanks

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [November 12, 2019, 8:49am UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/2 "2019-11-12T08:49:02Z")

</div>

Hi, welcome to the CodeCombat discourse.  
I don’t think you have your hammer equipped. Is that right?  
Danny

---

<div class="post-metadata">

**Author:** ![shicheng09](https://avatars.discourse-cdn.com/v4/letter/s/9fc29f/32.png) [@shicheng09](https://discourse.codecombat.com/u/shicheng09)\
**Post date:** [November 12, 2019, 4:00pm UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/3 "2019-11-12T16:00:06Z")

</div>

Thank you Danny you are right I changed hammer instead of sword.

---

<div class="post-metadata">

**Author:** ![helperdad](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/helperdad/32/11163_2.png) [@helperdad](https://discourse.codecombat.com/u/helperdad)\
**Post date:** [December 18, 2019, 4:40am UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/4 "2019-12-18T04:40:44Z")

</div>

Question for the CodeCombat team: does the error message presented by the OP seem correct to you? I was helping my daughter and we got the exact same error text, and unless I’m missing something, it seems totally incorrect. It references a “build” method and states that the argument type should be object, when in fact the method in question is buildXY and the argument type correctly is string. The second sentence (calling for a string) contradicts the first:

> > Line 11: ArgumentError:build’s argument toBuild should have type object, but got string:“fence”. You need a string to build; one of [“bear-trap”]

This error text was totally unhelpful, given that the issue is needing to equip the hammer.

---

<div class="post-metadata">

**Author:** ![wazi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wazi/32/14115_2.png) [@wazi](https://discourse.codecombat.com/u/wazi)\
**Post date:** [September 13, 2020, 10:40am UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/5 "2020-09-13T10:40:44Z")

</div>

hello, I need help with this  
while True:  
yak = hero.findNearestEnemy()  
if yak:

```
    yak.pos.y > hero.pos.y
       
    hero.buildXY("fence", yak.pos.x, yak.pos.y + 10)
    # else: 
    
    yak.pos.y < hero.pos.y
   
    hero.buildXY("fence", yak.pos.x, yak.pos.y - 10)
    
else:
   
    hero.moveXY(hero.pos.x + 10, hero.pos.y)
    pass
```

---

<div class="post-metadata">

**Author:** ![wazi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wazi/32/14115_2.png) [@wazi](https://discourse.codecombat.com/u/wazi)\
**Post date:** [September 13, 2020, 10:42am UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/6 "2020-09-13T10:42:23Z")

</div>

Is there any problem with my code?

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [September 13, 2020, 11:25am UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/7 "2020-09-13T11:25:55Z")

</div>

Can you format all of your code as it is described below?

> [@\[Essentials\] How To Post/Format Your Code Correctly](https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521):
>
> Formatting your code before posting code is essential to our community, and if you don’t we might not be able to help frowning Everyone must know how to format ALL of your code properly. It’s really easy and only requires a very small amount of effort. To post your code from the game , use the \</\> button or it won’t format properly. When you click the \</\> button, the following will appear: Please paste ALL …

Andrei

---

<div class="post-metadata">

**Author:** ![wazi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wazi/32/14115_2.png) [@wazi](https://discourse.codecombat.com/u/wazi)\
**Post date:** [September 13, 2020, 12:44pm UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/8 "2020-09-13T12:44:53Z")

</div>

yak = hero.findNearestEnemy()  
if yak:

`````python
    yak.pos.y > hero.pos.y
       
    hero.buildXY("fence", yak.pos.x, yak.pos.y + 10)
    
    
    yak.pos.y < hero.pos.y
   
    hero.buildXY("fence", yak.pos.x, yak.pos.y - 10)
    
else:
   
    hero.moveXY(hero.pos.x + 10, hero.pos.y)
    pass
````Preformatted text`
`````

---

<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:** [September 13, 2020, 12:54pm UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/9 "2020-09-13T12:54:59Z")

</div>

> [@wazi](#):
>
> `yak.pos.y > hero.pos.y`

I think you have to write:

```python
if yak.pos.y > hero.pos.y:

```

---

<div class="post-metadata">

**Author:** ![ONION165](https://avatars.discourse-cdn.com/v4/letter/o/e56c9b/32.png) [@ONION165](https://discourse.codecombat.com/u/ONION165)\
**Post date:** [April 9, 2024, 1:39pm UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/10 "2024-04-09T13:39:36Z")

</div>

Hey manes i am stucky on this level of ze codebombat please send codeified help.

---

<div class="post-metadata">

**Author:** ![ONION165](https://avatars.discourse-cdn.com/v4/letter/o/e56c9b/32.png) [@ONION165](https://discourse.codecombat.com/u/ONION165)\
**Post date:** [April 9, 2024, 1:40pm UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/11 "2024-04-09T13:40:10Z")

</div>

```python
# Move right, to the oasis.
# Build a "fence" above or below when you see a yak.

while True:
    yak = hero.findNearestEnemy()
    if yak:
        # If yak.pos.y is greater than hero.pos.y
        if yak.pos.y > hero.pos.y:
            # buildXY a "fence" 10m below the yak.
            hero.buildXY("fence", yak.pos.x, yak.pos.y - 10)
        # else: 
        else:
            # buildXY a "fence" 10m above the yak.
            hero.buildXY("fence", yak.pos.x, yak.pos.y + 10)
        pass
    else:
        # moveXY right 10m towards the oasis.
        hero.moveXY(61, 30)

```

---

<div class="post-metadata">

**Author:** ![ONION165](https://avatars.discourse-cdn.com/v4/letter/o/e56c9b/32.png) [@ONION165](https://discourse.codecombat.com/u/ONION165)\
**Post date:** [April 9, 2024, 1:40pm UTC](https://discourse.codecombat.com/t/solved-python-code-error-on-thunderhooves/19600/12 "2024-04-09T13:40:56Z")

</div>

It does not put down the fence and the freaking YAk (That i hate) keeps on ramming me from behind.
