# Code Combat Computer Science 4 Level 12: Second Gem

**URL:** <https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778>\
**Category:** Level Help\
**Created:** [December 17, 2018, 2:07pm UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778 "2018-12-17T14:07:59Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zonquinst](https://avatars.discourse-cdn.com/v4/letter/z/e9a140/32.png) [@Zonquinst](https://discourse.codecombat.com/u/Zonquinst)\
**Post date:** [December 17, 2018, 2:07pm UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778/1 "2018-12-17T14:07:59Z")

</div>

I can’t figure out what to do. Please help.

---

<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:** [December 17, 2018, 2:21pm UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778/2 "2018-12-17T14:21:52Z")

</div>

Hi,  
could you first read the FAQ, you find it by clicking on the toolbar, the three lines at the top right corner of the main screen, then click on the FAQ.  
It’s just so we can see your code, your problem and maybe even a screenshot or list of your equipment.  
Thanks,  
🦁 🦁 🦁

---

<div class="post-metadata">

**Author:** ![Zonquinst](https://avatars.discourse-cdn.com/v4/letter/z/e9a140/32.png) [@Zonquinst](https://discourse.codecombat.com/u/Zonquinst)\
**Post date:** [December 17, 2018, 2:45pm UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778/3 "2018-12-17T14:45:50Z")

</div>

```python
# One gem is safe, the others are bombs.
# But you know the answer: always take the second.

while True:
    items = hero.findItems()
    # If the length of items is greater or equal to 2:
    if items <= 2:
        # Move to the second item in items
        hero.moveXY(items[1].pos.x, items[1].pos.y)
    # Else:
    else:
        # Move to the center mark.
        hero.moveXY(39, 34)

```

I don’t quite know what to do for “if the length of items is greater or equal to 2:”

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [December 17, 2018, 3:17pm UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778/4 "2018-12-17T15:17:27Z")

</div>

> [@Zonquinst](#):
>
> ```python
> # If the length of items is greater or equal to 2:
> 
> ```

This is not what you have. You have:

```python
if items <= 2:

```

Follow the directions and it will work.

---

<div class="post-metadata">

**Author:** ![Zonquinst](https://avatars.discourse-cdn.com/v4/letter/z/e9a140/32.png) [@Zonquinst](https://discourse.codecombat.com/u/Zonquinst)\
**Post date:** [December 17, 2018, 3:29pm UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778/5 "2018-12-17T15:29:15Z")

</div>

I don’t know what to do for that part though. It says to find the length of it, but I’ve got no clue how.

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [December 17, 2018, 4:02pm UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778/6 "2018-12-17T16:02:14Z")

</div>

It doesn’t say to find the length. It says to write, “if the length of items is greater [than] or equal to 2”. Just write that. When you write that, the length doesn’t matter. The if conditional is true if the length is greater than or equal to 2. That’s all that matters. If this, then do that.

---

<div class="post-metadata">

**Author:** ![Zonquinst](https://avatars.discourse-cdn.com/v4/letter/z/e9a140/32.png) [@Zonquinst](https://discourse.codecombat.com/u/Zonquinst)\
**Post date:** [December 17, 2018, 4:53pm UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778/7 "2018-12-17T16:53:09Z")

</div>

But what do I put for that? If I say “if length.items \>= 2:” or “if items.length \>=2:” then it says that length is unidentified.

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [December 17, 2018, 4:55pm UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778/8 "2018-12-17T16:55:39Z")

</div>

Try:

```python
if len(items)

```

Then memorize this because you’re going to be seeing a ton of it.

---

<div class="post-metadata">

**Author:** ![Johnny\_Fuentes-McClu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/johnny_fuentes-mcclu/32/9830_2.png) [@Johnny\_Fuentes-McClu](https://discourse.codecombat.com/u/Johnny_Fuentes-McClu)\
**Post date:** [February 1, 2019, 4:31pm UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778/9 "2019-02-01T16:31:17Z")

</div>

hello im stuck on the same level but did it right, i know this because when I sub the _[1]_ out for another number the code works.

```python
// One gem is safe, the others are bombs.
// But you know the answer: always take the second.

while (true) {
    var items = hero.findItems();
    // If the length of items is greater or equal to 2:
    if(items.length >= 2){
        hero.moveXY(items[1].pos.x, items[1].pos.y);
    }
        // Move to the second item in items
    // Else:
    else {
        hero.moveXY(40, 33);
    }
        // Move to the center mark.
}

```

---

<div class="post-metadata">

**Author:** ![Terry\_Carstensen](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/terry_carstensen/32/13566_2.png) [@Terry\_Carstensen](https://discourse.codecombat.com/u/Terry_Carstensen)\
**Post date:** [August 11, 2020, 4:35am UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778/10 "2020-08-11T04:35:52Z")

</div>

Copy and paste the following, -maybe it’s the return to coordinates - hero.moveXY(40,34);

// One gem is safe, the others are bombs.  
// But you know the answer: always take the second.

while (true) {  
var items = hero.findItems();  
//  
if (items.length \>= 2) {  
// Move to the second item in items  
hero.moveXY(items[1].pos.x, items[1].pos.y);  
}  
// Else:  
else {  
// Move to the center mark.  
hero.moveXY(40, 34);  
}  
}

---

<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:** [August 11, 2020, 5:20am UTC](https://discourse.codecombat.com/t/code-combat-computer-science-4-level-12-second-gem/16778/11 "2020-08-11T05:20:44Z")

</div>

Hi @Terry_Carstensen and welcome to the forum! 🥳

Can you format your code as it is described below so we will be able to help you solve this level?

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