# Shine Getter Help Please

**URL:** <https://discourse.codecombat.com/t/shine-getter-help-please/39445>\
**Category:** Level Help\
**Created:** [December 11, 2024, 5:36pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445 "2024-12-11T17:36:06Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Jordan\_Student](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/james_jordan_student/32/44634_2.png) [@James\_Jordan\_Student](https://discourse.codecombat.com/u/James_Jordan_Student)\
**Post date:** [December 11, 2024, 5:36pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/1 "2024-12-11T17:36:06Z")

</div>

What is wrong with this code?

```python
# To grab the most gold quickly, just go after gold coins.
while True:
    coins = hero.findItems()
    coinIndex = 0
    # Wrap this into a loop that iterates over all coins.
    if coinIndex < len(coins):
        coin = coins[coinIndex]
    # Gold coins are worth 3.
    if coin.value == 3:
        # Only pick up gold coins.
        hero.moveXY(coin.pos.x, coin.pos.y)
    coinIndex += 1
    pass

```

---

<div class="post-metadata">

**Author:** ![Kyilan\_Davis-Kramer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kyilan_davis-kramer/32/45009_2.png) [@Kyilan\_Davis-Kramer](https://discourse.codecombat.com/u/Kyilan_Davis-Kramer)\
**Post date:** [December 11, 2024, 6:41pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/2 "2024-12-11T18:41:32Z")

</div>

You might want to use preformatted text so the Community can help you.

 ![Screenshot 2024-12-11 12.49.09 PM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/3/1/31390b6e5e6bd70dee2e80b15775fe8046f96e32.png)  
When posting a new topic for level help  
Use this to make it easier for the community  
Then, copy and paste your code, and then your good

---

<div class="post-metadata">

**Author:** ![Kyilan\_Davis-Kramer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kyilan_davis-kramer/32/45009_2.png) [@Kyilan\_Davis-Kramer](https://discourse.codecombat.com/u/Kyilan_Davis-Kramer)\
**Post date:** [December 11, 2024, 6:59pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/3 "2024-12-11T18:59:28Z")

</div>

Do you mind sending me the link to your level?  
Once you do I can see what is wrong with your code  
But if this is your actual code then you need indentation.

---

<div class="post-metadata">

**Author:** ![James\_Jordan\_Student](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/james_jordan_student/32/44634_2.png) [@James\_Jordan\_Student](https://discourse.codecombat.com/u/James_Jordan_Student)\
**Post date:** [December 11, 2024, 9:13pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/4 "2024-12-11T21:13:01Z")

</div>

Changed to add preformatted code!

---

<div class="post-metadata">

**Author:** ![JustALuke](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/justaluke/32/43608_2.png) [@JustALuke](https://discourse.codecombat.com/u/JustALuke)\
**Post date:** [December 12, 2024, 12:49am UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/5 "2024-12-12T00:49:56Z")

</div>

You can also guess the url of the level sometimes  
this one is [CodeCombat - Coding games to learn Python and JavaScript](http://codecombat.com/play/level/shine-getter)  
as you can see, the level name “shine getter” gets turned into “shine-getter” in the url

---

<div class="post-metadata">

**Author:** ![JustALuke](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/justaluke/32/43608_2.png) [@JustALuke](https://discourse.codecombat.com/u/JustALuke)\
**Post date:** [December 12, 2024, 12:56am UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/6 "2024-12-12T00:56:15Z")

</div>

> [@James\_Jordan\_Student](#):
>
> `if coinIndex < len(coins):`

this part needs to be a loop of some kind and not a if-statement (whether it be a for loop or a while loop)  
otherwise, the code will only execute once and then coinIndex will be reset and it will keep checking the same coin repeatedly  
if this is also your indentation, you may need to indent the

> [@James\_Jordan\_Student](#):
>
> `if coin.value == 3:`  
> ` hero.moveXY(coin.pos.x, coin.pos.y)`  
> `coinIndex += 1`

so that it is inside the new loop that you just created  
(this level is a bit annoying for that; it kinda mentions indenting but doesn’t make it clear)

---

<div class="post-metadata">

**Author:** ![Kyilan\_Davis-Kramer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kyilan_davis-kramer/32/45009_2.png) [@Kyilan\_Davis-Kramer](https://discourse.codecombat.com/u/Kyilan_Davis-Kramer)\
**Post date:** [December 12, 2024, 5:52pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/7 "2024-12-12T17:52:06Z")

</div>

So how do I help someone on a level I know the answer to? However I know what’s wrong with the code but I don’t know how to tell him to fix it without giving him the answer because he’s so close to getting it.

---

<div class="post-metadata">

**Author:** ![JustALuke](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/justaluke/32/43608_2.png) [@JustALuke](https://discourse.codecombat.com/u/JustALuke)\
**Post date:** [December 12, 2024, 5:55pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/8 "2024-12-12T17:55:40Z")

</div>

I think telling someone what to do (but not giving code) and more importantly, why their code wasn’t working / why the new code would work is fitting

---

<div class="post-metadata">

**Author:** ![Kyilan\_Davis-Kramer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kyilan_davis-kramer/32/45009_2.png) [@Kyilan\_Davis-Kramer](https://discourse.codecombat.com/u/Kyilan_Davis-Kramer)\
**Post date:** [December 12, 2024, 5:58pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/9 "2024-12-12T17:58:14Z")

</div>

ok so like if his is code is only running one time but I say I think you should maybe loop you code so the code can do it over again or do I say maybe you should think what do I need to make my code run the code over and over again?

---

<div class="post-metadata">

**Author:** ![JustALuke](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/justaluke/32/43608_2.png) [@JustALuke](https://discourse.codecombat.com/u/JustALuke)\
**Post date:** [December 12, 2024, 6:14pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/10 "2024-12-12T18:14:25Z")

</div>

I think the first is right for this situation (which is what I did)  
depends on the level; by this desert level (almost at the end) you should know how while loops work

---

<div class="post-metadata">

**Author:** ![Kyilan\_Davis-Kramer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kyilan_davis-kramer/32/45009_2.png) [@Kyilan\_Davis-Kramer](https://discourse.codecombat.com/u/Kyilan_Davis-Kramer)\
**Post date:** [December 12, 2024, 6:41pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/11 "2024-12-12T18:41:29Z")

</div>

Is it fine if I go ahead and say what he could do to change/improve you code

---

<div class="post-metadata">

**Author:** ![JustALuke](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/justaluke/32/43608_2.png) [@JustALuke](https://discourse.codecombat.com/u/JustALuke)\
**Post date:** [December 12, 2024, 6:44pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/12 "2024-12-12T18:44:32Z")

</div>

yeah I think so  
just not any complete code

---

<div class="post-metadata">

**Author:** ![Kyilan\_Davis-Kramer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kyilan_davis-kramer/32/45009_2.png) [@Kyilan\_Davis-Kramer](https://discourse.codecombat.com/u/Kyilan_Davis-Kramer)\
**Post date:** [December 12, 2024, 7:54pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/13 "2024-12-12T19:54:30Z")

</div>

> [@James\_Jordan\_Student](#):
>
> ```python
> # To grab the most gold quickly, just go after gold coins.
> while True:
> coins = hero.findItems()
> coinIndex = 0
> # Wrap this into a loop that iterates over all coins.
> if coinIndex < len(coins):
> coin = coins[coinIndex]
> # Gold coins are worth 3.
> if coin.value == 3:
> # Only pick up gold coins.
> hero.moveXY(coin.pos.x, coin.pos.y)
> coinIndex += 1
> pass
> 
> ```

A way to improve his code I would think would be the If/else statement that is causing the game to only run one code, which in this case he would need to change and probably use the while loop statement so it runs the other codes too, then it would break the infinite loop and then he’s good. @JustALuke does this sound like good help or is this like giving out the answer? which would be right here  
`if coinIndex < len(coins):`

---

<div class="post-metadata">

**Author:** ![JustALuke](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/justaluke/32/43608_2.png) [@JustALuke](https://discourse.codecombat.com/u/JustALuke)\
**Post date:** [December 12, 2024, 8:21pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/14 "2024-12-12T20:21:58Z")

</div>

yeah that’s good help  
just telling someone how to fix it

---

<div class="post-metadata">

**Author:** ![Kyilan\_Davis-Kramer](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kyilan_davis-kramer/32/45009_2.png) [@Kyilan\_Davis-Kramer](https://discourse.codecombat.com/u/Kyilan_Davis-Kramer)\
**Post date:** [December 12, 2024, 8:25pm UTC](https://discourse.codecombat.com/t/shine-getter-help-please/39445/15 "2024-12-12T20:25:27Z")

</div>

K cool I was just making sure because I’ve already done my research in posts, and it says not to just give them the answer even though I kinda did but however, also they kinda do get to experiment with it themselves.
