# Wishing Well (python) (help)

#1

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

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
#2
``````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

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
#3

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

#4

Thanks:sweat_smile: