# \[Solved\] Wishing Well (HELP NEEDED)

**URL:** <https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104>\
**Category:** Level Help\
**Created:** [July 4, 2018, 4:35am UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104 "2018-07-04T04:35:45Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naimaa1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/naimaa1/32/9542_2.png) [@Naimaa1](https://discourse.codecombat.com/u/Naimaa1)\
**Post date:** [July 4, 2018, 4:35am UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/1 "2018-07-04T04:35:45Z")

</div>

Hello, I was wondering if you could help me out with this level and i’m not sure what i’m doing wrong.

Here’s my code:

```python
# You need exactly 104 gold. 

less = "Nimis"
more = "Non satis"
requiredGold = 104

# This function calculates the sum of all coin values.
def sumCoinValues(coins):
    coinIndex = 0
    totalValue = 0
    # Iterate all coins.
    while coinIndex < len(coins):
        totalValue += coins[coinIndex].value
        coinIndex += 1
    return totalValue

def collectAllCoins():
    item = hero.findNearest(hero.findItems())
    while item:
        hero.moveXY(item.pos.x, item.pos.y)
        item = hero.findNearest(hero.findItems())

while True:
    items = hero.findItems()
    # Get the total value of coins.
    goldAmount = sumCoinValues(items)
    # If there are coins, then goldAmount isn't zero.
    if goldAmount != 0:
        # If goldAmount is less than requiredGold
        if goldAmount < requiredGold:
            # Then say "Non satis".
            hero.say("Non satis")
        # If goldAmount is greater than requiredGold
        if goldAmount > requiredGold:
            # Then say "Nimis".
            hero.say("Nimis")
        # If goldAmount is exactly equal to requiredGold
        if goldAmount != requiredGold:
            # Then collect all coins:
            items = hero.findItems()
        pass

```

---

<div class="post-metadata">

**Author:** ![Archion](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/archion/32/26234_2.png) [@Archion](https://discourse.codecombat.com/u/Archion)\
**Post date:** [July 4, 2018, 5:14am UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/2 "2018-07-04T05:14:46Z")

</div>

One you are saying `!= requiredGold` and second you are not calling on the function for requiredGold. Firt put the `!=` to `==` then call on the `collectAllCoins` function @Naimaa1

---

<div class="post-metadata">

**Author:** ![Naimaa1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/naimaa1/32/9542_2.png) [@Naimaa1](https://discourse.codecombat.com/u/Naimaa1)\
**Post date:** [July 5, 2018, 5:27pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/3 "2018-07-05T17:27:12Z")

</div>

Okay I fixed it, but it still says it’s wrong.

Here’s my code:

```python
# You need exactly 104 gold. 

less = "Nimis"
more = "Non satis"
requiredGold = 104

# This function calculates the sum of all coin values.
def sumCoinValues(coins):
    coinIndex = 0
    totalValue = 0
    # Iterate all coins.
    while coinIndex < len(coins):
        totalValue += coins[coinIndex].value
        coinIndex += 1
    return totalValue

def collectAllCoins():
    item = hero.findNearest(hero.findItems())
    while item:
        hero.moveXY(item.pos.x, item.pos.y)
        item = hero.findNearest(hero.findItems())

while True:
    items = hero.findItems()
    # Get the total value of coins.
    goldAmount = sumCoinValues(items)
    # If there are coins, then goldAmount isn't zero.
    if goldAmount != 0:
        # If goldAmount is less than requiredGold
        if goldAmount < requiredGold:
            # Then say "Non satis".
            hero.say("Non satis")
        # If goldAmount is greater than requiredGold
        if goldAmount > requiredGold:
            # Then say "Nimis".
            hero.say("Nimis")
        # If goldAmount is exactly equal to requiredGold
        if goldAmount == requiredGold:
            # Then collect all coins:
            collectAllCoins():
                items = hero.findItems()
            pass

```

---

<div class="post-metadata">

**Author:** ![Naimaa1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/naimaa1/32/9542_2.png) [@Naimaa1](https://discourse.codecombat.com/u/Naimaa1)\
**Post date:** [July 5, 2018, 6:25pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/4 "2018-07-05T18:25:54Z")

</div>

Guys i need help [@everyone](https://discourse.codecombat.com/groups/everyone)

---

<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:** [July 5, 2018, 6:26pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/5 "2018-07-05T18:26:10Z")

</div>

Don’t worry I just solved it.

---

<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:** [July 5, 2018, 6:27pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/6 "2018-07-05T18:27:47Z")

</div>

Look at this line:

> [@Naimaa1](#):
>
> ```python
> collectAllCoins(): 
> items = hero.findItems()
> 
> ```

This doesn’t make sense, you can’t put a colon behind a function, in fact you don’t even need it, or the ` items = hero.findItems()`. It works fine apart from that.

---

<div class="post-metadata">

**Author:** ![Naimaa1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/naimaa1/32/9542_2.png) [@Naimaa1](https://discourse.codecombat.com/u/Naimaa1)\
**Post date:** [July 5, 2018, 6:30pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/7 "2018-07-05T18:30:50Z")

</div>

```python
# You need exactly 104 gold. 

less = "Nimis"
more = "Non satis"
requiredGold = 104

# This function calculates the sum of all coin values.
def sumCoinValues(coins):
    coinIndex = 0
    totalValue = 0
    # Iterate all coins.
    while coinIndex < len(coins):
        totalValue += coins[coinIndex].value
        coinIndex += 1
    return totalValue

def collectAllCoins():
    item = hero.findNearest(hero.findItems())
    while item:
        hero.moveXY(item.pos.x, item.pos.y)
        item = hero.findNearest(hero.findItems())

while True:
    items = hero.findItems()
    # Get the total value of coins.
    goldAmount = sumCoinValues(items)
    # If there are coins, then goldAmount isn't zero.
    if goldAmount != 0:
        # If goldAmount is less than requiredGold
        if goldAmount < requiredGold:
            # Then say "Non satis".
            hero.say("Non satis")
        # If goldAmount is greater than requiredGold
        if goldAmount > requiredGold:
            # Then say "Nimis".
            hero.say("Nimis")
        # If goldAmount is exactly equal to requiredGold
        if goldAmount == requiredGold:
            # Then collect all coins:
            items = hero.findItems()
            pass

```

---

<div class="post-metadata">

**Author:** ![Naimaa1](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/naimaa1/32/9542_2.png) [@Naimaa1](https://discourse.codecombat.com/u/Naimaa1)\
**Post date:** [July 5, 2018, 6:31pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/8 "2018-07-05T18:31:11Z")

</div>

it says ran out of time.

---

<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:** [July 5, 2018, 6:38pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/9 "2018-07-05T18:38:10Z")

</div>

No, I meant keep the “collect coins” and get rid of the items = hero.findItems() and the colon.

---

<div class="post-metadata">

**Author:** ![Archion](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/archion/32/26234_2.png) [@Archion](https://discourse.codecombat.com/u/Archion)\
**Post date:** [July 8, 2018, 2:26am UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/10 "2018-07-08T02:26:09Z")

</div>

Yea i agree. Sorry i couldn’t have helped sooner. I was away

---

<div class="post-metadata">

**Author:** ![SuperSmacker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/supersmacker/32/8385_2.png) [@SuperSmacker](https://discourse.codecombat.com/u/SuperSmacker)\
**Post date:** [July 8, 2018, 8:32pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/11 "2018-07-08T20:32:22Z")

</div>

Look at the goldAmount == requiredGold if loop.

It says to collect all the coins.

You didn’t do that.

Of course it runs out of time.

Did you solve the problem yet? If so, please tell us so that we can mark the topic as solved.

---

<div class="post-metadata">

**Author:** ![dragonsboy0](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dragonsboy0/32/15935_2.png) [@dragonsboy0](https://discourse.codecombat.com/u/dragonsboy0)\
**Post date:** [October 28, 2020, 6:05pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/12 "2020-10-28T18:05:32Z")

</div>

i got this # You need exactly 104 gold.

less = “Nimis”  
more = “Non satis”  
requiredGold = 104

# This function calculates the sum of all coin values.

def sumCoinValues(coins):  
coinIndex = 0  
totalValue = 0  
# Iterate all coins.  
while coinIndex \< len(coins):  
totalValue += coins[coinIndex].value  
coinIndex += 1  
return totalValue

def collectAllCoins():  
item = hero.findNearest(hero.findItems())  
while item:  
hero.moveXY(item.pos.x, item.pos.y)  
item = hero.findNearest(hero.findItems())

while True:  
items = hero.findItems()  
# Get the total value of coins.  
goldAmount = sumCoinValues(items)  
# If there are coins, then goldAmount isn’t zero.  
if goldAmount != 0:  
# If goldAmount is less than requiredGold  
if goldAmount \< requiredGold:  
# Then say “Non satis”.  
hero.say(“Non satis”)  
# If goldAmount is greater than requiredGold  
if goldAmount \> requiredGold:  
# Then say “Nimis”.  
hero.say(“Nimis”)  
# If goldAmount is exactly equal to requiredGold  
if goldAmount == requiredGold:  
# Then collect all coins:  
(collectAllCoins():  
pass  
and im confused it isn’t working

---

<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:** [October 28, 2020, 6:07pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/13 "2020-10-28T18:07:41Z")

</div>

Hi @dragonsboy0, welcome to the forum! 🎉  
Please could you post your code formatted so we can see the spaces. To format code you put three ``` (backticks not quotes) on a new line at the start and end of your code to format it.  
Danny

---

<div class="post-metadata">

**Author:** ![dragonsboy0](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dragonsboy0/32/15935_2.png) [@dragonsboy0](https://discourse.codecombat.com/u/dragonsboy0)\
**Post date:** [October 29, 2020, 2:12pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/14 "2020-10-29T14:12:26Z")

</div>

less = “Nimis”  
more = “Non satis”  
requiredGold = 104

# This function calculates the sum of coin values.

def sumCoinValues(coins):  
i = 0  
total = 0  
while i \< len(coins):  
total += coins[i].value  
i += 1  
return total

while True:  
items = hero.findItems()  
goldAmount = sumCoinValues(items)  
if len(items) != 0:  
# If there is not enough gold, then say “Non satis”.  
if goldAmount \> 104:  
# If there is too much gold, then say “Nimis”.  
hero.say(less)  
# If there is exactly 104 gold, then collect all coins.  
if goldAmount \< 104:  
hero.say(more)  
pass  
if goldAmount == 104:  
break  
while True:  
items = hero.findItems()  
item = hero.findNearest(items)  
if item:  
hero.moveXY(41, 19)  
hero.moveXY(55, 18)  
hero.moveXY(60, 29)  
hero.moveXY(41, 19)  
hero.moveXY(51, 46)  
hero.moveXY(58, 34)  
hero.moveXY(20, 40)  
hero.moveXY(24, 18)  
hero.moveXY(40, 46)  
hero.moveXY(33, 45)  
hero.moveXY(25, 35)  
hero.moveXY(35, 18)  
hero.moveXY(28, 25)  
hero.moveXY(32, 19)  
hero.moveXY(38, 25)  
hero.moveXY(59, 44)  
hero.moveXY(27, 18)  
hero.moveXY(24, 46)  
hero.moveXY(53, 33)

this?

---

<div class="post-metadata">

**Author:** ![dragonsboy0](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dragonsboy0/32/15935_2.png) [@dragonsboy0](https://discourse.codecombat.com/u/dragonsboy0)\
**Post date:** [October 29, 2020, 2:13pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/15 "2020-10-29T14:13:00Z")

</div>

no i did it wrong man how do u do it ? sorry

---

<div class="post-metadata">

**Author:** ![dragonsboy0](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dragonsboy0/32/15935_2.png) [@dragonsboy0](https://discourse.codecombat.com/u/dragonsboy0)\
**Post date:** [October 29, 2020, 2:18pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/16 "2020-10-29T14:18:16Z")

</div>

```python
less = "Nimis"
more = "Non satis"
requiredGold = 104

# This function calculates the sum of coin values.
def sumCoinValues(coins):
    i = 0
    total = 0
    while i < len(coins):
        total += coins[i].value
        i += 1
    return total

while True:
    items = hero.findItems()
    goldAmount = sumCoinValues(items)
    if len(items) != 0:
        # If there is not enough gold, then say "Non satis".
        if goldAmount > 104:
            # If there is too much gold, then say "Nimis".
            hero.say(less)
        # If there is exactly 104 gold, then collect all coins.
        if goldAmount < 104:
            hero.say(more)
        pass
        if goldAmount == 104:
            break
while True:
    items = hero.findItems()
    item = hero.findNearest(items)
    if item:
        hero.moveXY(41, 19)
        hero.moveXY(55, 18)
        hero.moveXY(60, 29)
        hero.moveXY(41, 19)
        hero.moveXY(51, 46)
        hero.moveXY(58, 34)
        hero.moveXY(20, 40)
        hero.moveXY(24, 18)
        hero.moveXY(40, 46)
        hero.moveXY(33, 45)
        hero.moveXY(25, 35)
        hero.moveXY(35, 18)
        hero.moveXY(28, 25)
        hero.moveXY(32, 19)
        hero.moveXY(38, 25)
        hero.moveXY(59, 44)
        hero.moveXY(27, 18)
        hero.moveXY(24, 46)
        hero.moveXY(53, 33)
        

```

ok i did it

![Screenshot 2020-10-29 at 10.23.16 AM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/5/5819be77910ab3a5d4b96caa32b417e99841e1b9.png)  
 ![Screenshot 2020-10-29 at 10.19.44 AM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/4/4637d765d37f807ded354b138197872013da797e.png)

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [October 29, 2020, 4:10pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/17 "2020-10-29T16:10:26Z")

</div>

Delete this:

> [@dragonsboy0](#):
>
> `if len(items) != 0:`

and this:

> [@dragonsboy0](#):
>
> ```python
> while True:
> items = hero.findItems()
> item = hero.findNearest(items)
> if item:
> hero.moveXY(41, 19)
> hero.moveXY(55, 18)
> hero.moveXY(60, 29)
> hero.moveXY(41, 19)
> hero.moveXY(51, 46)
> hero.moveXY(58, 34)
> hero.moveXY(20, 40)
> hero.moveXY(24, 18)
> hero.moveXY(40, 46)
> hero.moveXY(33, 45)
> hero.moveXY(25, 35)
> hero.moveXY(35, 18)
> hero.moveXY(28, 25)
> hero.moveXY(32, 19)
> hero.moveXY(38, 25)
> hero.moveXY(59, 44)
> hero.moveXY(27, 18)
> hero.moveXY(24, 46)
> hero.moveXY(53, 33)
>         
> 
> ```

Delete an indent in this part:

> [@dragonsboy0](#):
>
> ```python
> if goldAmount > 104:
> # If there is too much gold, then say "Nimis".
> hero.say(less)
> # If there is exactly 104 gold, then collect all coins.
> if goldAmount < 104:
> hero.say(more)
> pass
> if goldAmount == 104:
> break
> 
> ```

Replace all 104 with requiredGold

> [@dragonsboy0](#):
>
> `104`

Should be Non satis:

> [@dragonsboy0](#):
>
> `less`

Should be Nimis:

> [@dragonsboy0](#):
>
> `more`

Replace with

> [@dragonsboy0](#):
>
> ```python
> break
> 
> ```

this:

```python
coin = hero.findNearestItem()
            while coin:
                
                # Then collect all coins:
                hero.moveXY(coin.pos.x, coin.pos.y)
                coin = hero.findNearestItem()
                
        pass

```

Lydia

---

<div class="post-metadata">

**Author:** ![dragonsboy0](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dragonsboy0/32/15935_2.png) [@dragonsboy0](https://discourse.codecombat.com/u/dragonsboy0)\
**Post date:** [October 29, 2020, 4:36pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/18 "2020-10-29T16:36:04Z")

</div>

ok lemme try this  
yeah it worked your the best thx

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [October 29, 2020, 4:54pm UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/19 "2020-10-29T16:54:38Z")

</div>

No problem! Glad to hear you passed!  
Lydis

---

<div class="post-metadata">

**Author:** ![WaWa\_Yang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/wawa_yang/32/17800_2.png) [@WaWa\_Yang](https://discourse.codecombat.com/u/WaWa_Yang)\
**Post date:** [November 9, 2020, 12:35am UTC](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104/20 "2020-11-09T00:35:47Z")

</div>

Hi i need help for the same level heres my code:

```python
# You need exactly 104 gold. 

less = "Nimis"
more = "Non satis"
requiredGold = 104

# This function calculates the sum of all coin values.
def sumCoinValues(coins):
    coinIndex = 0
    totalValue = 0
    # Iterate all coins.
    while coinIndex < len(coins):
        totalValue += coins[coinIndex].value
        coinIndex += 1
    return totalValue

def collectAllCoins():
    item = hero.findNearest(hero.findItems())
    while item:
        hero.moveXY(item.pos.x, item.pos.y)
        item = hero.findNearest(hero.findItems())

while True:
    coin = hero.findItems()
    # Get the total value of coins.
    goldAmount = sumCoinValues(coin)
    # If there are coins, then goldAmount isn't zero.
    if goldAmount != 0:
        # If goldAmount is less than requiredGold
        if goldAmount < requiredGold:
            # Then say "Non satis".
            hero.say(less)
        # If goldAmount is greater than requiredGold
        if goldAmount > requiredGold:
            # Then say "Nimis".
            hero.say(more)
        # If goldAmount is exactly equal to requiredGold
        if goldAmount == requiredGold:
            # Then collect all coins:
            return collectAllCoins()
        pass

```

it keeps adding up to 190 help pls

[Next page](https://discourse.codecombat.com/t/solved-wishing-well-help-needed/15104.md?page=2)
