[SOLVED] Wishing Well

Hello I was wondering if someone could point out any mistakes that would help me pass this level

# 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 < 104:
            # Then say "Non satis".
            hero.say("Non statis")
        # If goldAmount is greater than requiredGold
        if goldAmount > 104:
            # Then say "Nimis".
            hero.say("Nimis")
        # If goldAmount is exactly equal to requiredGold
        if goldAmount == 104:
            # Then collect all coins:
            item = hero.findNearestItem()
            hero.moveXY(item.pos.x, item.pos.y)
        pass

1 Like

never mind I got it!

2 Likes

How do you do it?

Hi @MrEric20, please don’t revive old topics. The people who posted on them are almost always inactive now.
Instead please make a new post here, or on a new topic, which your code and a description of your problem.
Make sure you read this topic to learn how to format your code:
[Essentials] How To Post/Format Your Code Correctly
Danny