# To grab the most gold quickly, just go after gold coins.
while True:
coins = hero.findItems()
coinIndex = 0
# Wrap this into a loop that iterates over all coins.
if coinIndex < len(coins):
coin = coins[coinIndex]
# Gold coins are worth 3.
if coin.value == 3:
# Only pick up gold coins.
hero.moveXY(coin.pos.x, coin.pos.y)
coinIndex += 1
pass
Do you mind sending me the link to your level?
Once you do I can see what is wrong with your code
But if this is your actual code then you need indentation.
this part needs to be a loop of some kind and not a if-statement (whether it be a for loop or a while loop)
otherwise, the code will only execute once and then coinIndex will be reset and it will keep checking the same coin repeatedly
if this is also your indentation, you may need to indent the
so that it is inside the new loop that you just created
(this level is a bit annoying for that; it kinda mentions indenting but doesn’t make it clear)
So how do I help someone on a level I know the answer to? However I know what’s wrong with the code but I don’t know how to tell him to fix it without giving him the answer because he’s so close to getting it.
I think telling someone what to do (but not giving code) and more importantly, why their code wasn’t working / why the new code would work is fitting
ok so like if his is code is only running one time but I say I think you should maybe loop you code so the code can do it over again or do I say maybe you should think what do I need to make my code run the code over and over again?
I think the first is right for this situation (which is what I did)
depends on the level; by this desert level (almost at the end) you should know how while loops work
A way to improve his code I would think would be the If/else statement that is causing the game to only run one code, which in this case he would need to change and probably use the while loop statement so it runs the other codes too, then it would break the infinite loop and then he’s good. @JustALuke does this sound like good help or is this like giving out the answer? which would be right here if coinIndex < len(coins):
K cool I was just making sure because I’ve already done my research in posts, and it says not to just give them the answer even though I kinda did but however, also they kinda do get to experiment with it themselves.