Wishing Well (python) (help)

This is my code ```less = "Nimis"
more = "Non satis"
requiredGold = 104

This function calculates the sum of coin values.

def sumCoinValues(coins):
total = 0
for coin in coins:
total += coin.value
return total

def collectCoins(coins):
for coin in coins:
hero.moveXY(coin.pos.x, coin.pos.y)

while True:
items = hero.findItems()
goldAmount = sumCoinValues(items)
if len(items) != 0:
# If there is not enough gold, then say “Non satis”.
if goldAmount < requiredGold:
hero.say(“Nimis”)
elif goldAmount > requiredGold:
hero.say(“non satis”)
elif goldAmount == requiredGold:
collectCoins(items)

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

# This function calculates the sum of coin values. 
def sumCoinValues(coins):
    total = 0
    for coin in coins:
        total += coin.value
    return total

def collectCoins(coins):
    for coin in coins:
        hero.moveXY(coin.pos.x, coin.pos.y)

while True:
    items = hero.findItems()
    goldAmount = sumCoinValues(items)
    if len(items) != 0:
        # If there is not enough gold, then say "Non satis".
        if goldAmount < requiredGold:
            hero.say("Nimis")
        elif goldAmount > requiredGold:
            hero.say("non satis")
        elif goldAmount == requiredGold:
            collectCoins(items)

1 Like

Use variables instead of the strings themselves (it’s confusing, I know, I made the same mistake too).

Thanks:sweat_smile::smiley: