# Sarven Sentry Python help

**URL:** <https://discourse.codecombat.com/t/sarven-sentry-python-help/7410>\
**Category:** Level Help\
**Created:** [May 3, 2016, 2:09am UTC](https://discourse.codecombat.com/t/sarven-sentry-python-help/7410 "2016-05-03T02:09:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dauntee.lowrance](https://avatars.discourse-cdn.com/v4/letter/d/57b2e6/32.png) [@dauntee.lowrance](https://discourse.codecombat.com/u/dauntee.lowrance)\
**Post date:** [May 3, 2016, 2:09am UTC](https://discourse.codecombat.com/t/sarven-sentry-python-help/7410/1 "2016-05-03T02:09:13Z")

</div>

```python
flagGreen = self.findFlag("green")
flagBlack = self.findFlag("black")
flagViolet = self.findFlag("violet")
if flagGreen: 
    self.moveXY(flagGreen.pos.x, flagBlack.pos.y)
    self.pickUpFlag(flagGreen)
    self.buildXY("fence", self.pos.x, self.pos.y)  
 elif flagBlack:
    self.moveXY(flagBlack.pos.x, flagBlack.pos.y)
    self.pickUpFlag(flagBlack)
    self.buildXY("fire-trap", self.pos.x, self.pos.y)      
 elif flagViolet:
    self.pickUpFlag(flagViolet)

```

I can’t figure out why it is going wrong and not working. Could someone please help with this I can’t find the error.

---

<div class="post-metadata">

**Author:** ![zimmah](https://avatars.discourse-cdn.com/v4/letter/z/9e8a1a/32.png) [@zimmah](https://discourse.codecombat.com/u/zimmah)\
**Post date:** [May 3, 2016, 3:10am UTC](https://discourse.codecombat.com/t/sarven-sentry-python-help/7410/2 "2016-05-03T03:10:11Z")

</div>

please surround your code with three of these things ` so it’s easier to read (three above and three below the code)

```python
if flagGreen: 
    self.moveXY(flagGreen.pos.x, flagBlack.pos.y)

```

something is not quite right here

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [May 3, 2016, 4:26am UTC](https://discourse.codecombat.com/t/sarven-sentry-python-help/7410/3 "2016-05-03T04:26:18Z")

</div>

Yes, as zimmah has said, surround your code with backticks, which is the key directly above the `Tab` key. See the FAQ for more information. I have formatted your code for you this time, but please do so yourself in the future.

Two things:  
You have not surrounded your code in a loop.  
Also, your `elif` statements are indented by one space. This should not be.

---

<div class="post-metadata">

**Author:** ![Armin\_Alimohammadi](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/armin_alimohammadi/32/13370_2.png) [@Armin\_Alimohammadi](https://discourse.codecombat.com/u/Armin_Alimohammadi)\
**Post date:** [July 31, 2020, 5:57pm UTC](https://discourse.codecombat.com/t/sarven-sentry-python-help/7410/4 "2020-07-31T17:57:59Z")

</div>

```python
# Use different colored flags to perform different tasks.

while True:
    flagGreen = hero.findFlag("green")
    flagBlack = hero.findFlag("black")
    
    # If there's a flagGreen...
    if flagGreen:
        hero.moveXY(flagGreen, pos.x, flagBlack.pos.y)
        # Build a "fence" at flagGreen's position.
        hero.buildXY("fence", Xpos.x, Ypos.y)
        
        # Pick up the flag!
        hero.pickUpFlag(flag)
    # If there's a flagBlack...
    if flagBlack:
        # Build a "fire-trap" at flagBlack's position.
        
        # Pick up the flag!
        
    # Move back to the center.
        hero.moveXY(43, 31)

```

i dont know what to do .I cant understand.I cant keep on.why use (flagGreen, pos.x )as x and (flagBlack.pos.y) as y .

---

<div class="post-metadata">

**Author:** ![MidnightWolf39](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/midnightwolf39/32/13309_2.png) [@MidnightWolf39](https://discourse.codecombat.com/u/MidnightWolf39)\
**Post date:** [July 31, 2020, 6:16pm UTC](https://discourse.codecombat.com/t/sarven-sentry-python-help/7410/5 "2020-07-31T18:16:35Z")

</div>

> [@Armin\_Alimohammadi](#):
>
> ```python
> if flagGreen:
> hero.moveXY(flagGreen, pos.x, flagBlack.pos.y)
> # Build a "fence" at flagGreen's position.
> hero.buildXY("fence", Xpos.x, Ypos.y)
>         
> # Pick up the flag!
> hero.pickUpFlag(flag)
>  
> 
> ```

You haven’t defined Xpos, Ypos, or flag.

> [@Armin\_Alimohammadi](#):
>
> `hero.moveXY(flagGreen, pos.x, flagBlack.pos.y)`

You don’t need that.

> [@Armin\_Alimohammadi](#):
>
> `hero.buildXY("fence", Xpos.x, Ypos.y)`

You should be building at flagGreen’s pos.x and pos.y

> [@Armin\_Alimohammadi](#):
>
> ```python
> if flagBlack:
> # Build a "fire-trap" at flagBlack's position.
>         
> # Pick up the flag!
>         
> 
> ```

Build a “fire-trap” at flagBlack’s pos.x and pos.y then pickUpFlag() flagBlack.

---

<div class="post-metadata">

**Author:** ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)\
**Post date:** [August 1, 2020, 3:12am UTC](https://discourse.codecombat.com/t/sarven-sentry-python-help/7410/6 "2020-08-01T03:12:50Z")

</div>

Try look through the hints on the top right corner before asking more questions.  
If you have any more questions after reading the hints section feel free to tell us your issue 😄

 ![Screenshot 2020-08-01 at 11.08.06 AM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/2/24f6cfb3881099cbe7c4e247327175b7f5f65e88.jpeg)
