# Https://codecombat.com/play/level/second-gem?

**URL:** <https://discourse.codecombat.com/t/https-codecombat-com-play-level-second-gem/17179>\
**Category:** русский (Russian)\
**Created:** [January 21, 2019, 12:17pm UTC](https://discourse.codecombat.com/t/https-codecombat-com-play-level-second-gem/17179 "2019-01-21T12:17:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ab7d2c9c21c829b554fb](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@ab7d2c9c21c829b554fb](https://discourse.codecombat.com/u/ab7d2c9c21c829b554fb)\
**Post date:** [January 21, 2019, 12:17pm UTC](https://discourse.codecombat.com/t/https-codecombat-com-play-level-second-gem/17179/1 "2019-01-21T12:17:30Z")

</div>

Hello. help with the task “second gem” in the desert. it seems the code is correct. after the second cycle, the gems no longer come out.

---

<div class="post-metadata">

**Author:** ![ab7d2c9c21c829b554fb](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@ab7d2c9c21c829b554fb](https://discourse.codecombat.com/u/ab7d2c9c21c829b554fb)\
**Post date:** [January 21, 2019, 12:22pm UTC](https://discourse.codecombat.com/t/https-codecombat-com-play-level-second-gem/17179/2 "2019-01-21T12:22:25Z")

</div>

```python
while True:
    items = hero.findItems()
    # Если длина массива больше или равна 2:
    gem2=items[1]
    if len(items)>=2:
        # Двигайся ко второму предмету массива.
        hero.moveXY(gem2.pos.x, gem2.pos.y)
    # Иначе:
    else:
        # Двигайся в центр.
        hero.moveXY(40, 33)

```

---

<div class="post-metadata">

**Author:** ![Chaboi\_3000](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chaboi_3000/32/48486_2.png) [@Chaboi\_3000](https://discourse.codecombat.com/u/Chaboi_3000)\
**Post date:** [January 21, 2019, 9:46pm UTC](https://discourse.codecombat.com/t/https-codecombat-com-play-level-second-gem/17179/3 "2019-01-21T21:46:05Z")

</div>

Please learn to post your code correctly. The way it is now, we can’t see the structure. Help us help you. It’s very easy to do and just takes a tiny bit of effort. Please read this topic and format your code again correctly

> [@\[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 …

---

<div class="post-metadata">

**Author:** ![ab7d2c9c21c829b554fb](https://avatars.discourse-cdn.com/v4/letter/a/54ee81/32.png) [@ab7d2c9c21c829b554fb](https://discourse.codecombat.com/u/ab7d2c9c21c829b554fb)\
**Post date:** [January 22, 2019, 5:29am UTC](https://discourse.codecombat.com/t/https-codecombat-com-play-level-second-gem/17179/4 "2019-01-22T05:29:42Z")

</div>

here did … and what’s the difference? why the first code didn’t work?  
Mod edit: Please do not post successful solutions.

---

<div class="post-metadata">

**Author:** ![Chaboi\_3000](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chaboi_3000/32/48486_2.png) [@Chaboi\_3000](https://discourse.codecombat.com/u/Chaboi_3000)\
**Post date:** [January 22, 2019, 8:09am UTC](https://discourse.codecombat.com/t/https-codecombat-com-play-level-second-gem/17179/5 "2019-01-22T08:09:14Z")

</div>

We do not post successful solutions on the board, as it interferes with learning. The difference between the first code and the second code is that in the first code you’re checking the second gem before the length of the gem is greater than or equal to 2. While in the second code, you are checking the second gem **after** the length of the gem is greater than or equal to 2.
