Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Why ut isnt working?it keeps saying wrong value of coins


Collect coins until the clock reaches 30 seconds.

totalGold = 0
while True:
gold = hero.findNearestItem()
if gold:
hero.moveXY(gold.pos.x, gold.pos.y)
totalGold += gold.value
if < 30:

Tell Naria how much gold you collected.

hero.moveXY(58, 33)


This line seems odd:

if < 30:

It looks like you should break out of the coin collection loop when the clock is >= 30 seconds.


but it says to collec5t coins until 30 sec


and ive tried to write as you wrote >=30 it is not working neither


it just keeps saying wrong value of collected coins


Are you playing “Hoarding Gold” or is it a different level?


This level is BOOKEEPER


what is really interseting when 5 min ago when i run it it was working it even showed “success” and now i cant figure out whats wrong


Oh I see.

It sometimes happens that your hero walks into more than one coin while moving to collect a coin. Try resubmitting (click “Submit”) again to see if it helps.

Also, I’ve just took a look at the sample code for the level, it should be if > 30: then break out of the loop (that is, stop collecting).


no it is not working:sob: i wrote as you said and tried resubmit
if > 30:


Well, your code seems correct.

In any case, although in this level you are supposed to count the collected gold manually, you should be able to use as well if your pendant is good enough.

Try with hero.say( to check.


i ve already put sample code so it worked and yes you are right in sampke code they used isnt it the same as my code? I mean they have to work in same way


astill dont understand why it is rejecting my code

#15 is the actual amount of gold your hero has at the moment, so it is 100% bulletproof for this level.

On the other hand, manually counting the gold you’ve collected can result in issues when you are walking towards a coin and your hero unexpectedly collects another coin that just spawned in the way, or when two coins spawn too close to each other and your hero collects both counting as just one. This is why I suggested resubmitting, every time you press “Submit” (not “run”) you get a new random seed and your game plays differently.

Did you manage to beat the level? If not, please post your updated code so I could try it here as well.


Yes I beat this level FINALLY :sweat_smile: althougn with sample code .But thank you anyway your advices were really helpfull