[SOLVED] Help with golden mirage please

is that supposed to be in the while loop?

Yes. Have you completed the level?

he tries to get all the coins at the same time.

Can you show me your code?

here:

while True:
    coins = hero.findItems()
    i = 0
    while i < len(coins):
        coinA = coins[i]
        j = 0
        k = 0
        coinB = coins[j]
        while j < len(coins):
            if (coinA == coinB) and (i != j):
                k = i
                break
            j += 1
        if k == 0:
            hero.move(coinA.pos)
            i += 1

Put k = 1. Does it work now?

sorry, here’s the code

while True:
    coins = hero.findItems()
    i = 0
    while i < len(coins):
        coinA = coins[i]
        j = 0
        k = 0
        coinB = coins[j]
        while j < len(coins):
            if (coinA == coinB) and (i != j):
                k = 1
                break
            j += 1
        if k == 0:
            hero.move(coinA.pos)
            i += 1

but it says that there’s an infinite loop

Delete this.

Put this outside the if statement. Does it work now?

no… it still does the same thing

Can you resend me your code?

here:

while True:
    coins = hero.findItems()
    i = 0
    while i < len(coins):
        coinA = coins[i]
        j = 0
        k = 0
        coinB = coins[j]
        while j < len(coins):
            if (coinA == coinB) and (i != j):
                break
            j += 1
        if k == 0:
            hero.move(coinA.pos)
        i += 1

Put that after this

Does it work now?

don’t i already have a while loop there @AnSeDra?

Put coins[j] at the beggining of this while loop.

Do you need any more assistance at this level?

where exactly do i put

?

Like this

while j < len(coins):
    coinB = coins[j]
    #here continue the code

Have you completed the level?

it doesn’t change anything

Can you show me your code?

here:

while True:
    coins = hero.findItems()
    i = 0
    while i < len(coins):
        coinA = coins[i]
        j = 0
        k = 0
        while j < len(coins):
            coinB = coins[j]
            if (coinA == coinB) and (i != j):
                break
            j += 1
        if k == 0:
            hero.move(coinA.pos)
        i += 1

Put

coinA.value == coinB.value

Does it work now?