Help on Gridmancer Redux

Can you help me? I just do not know what is wrong with my code. Here it is:

# Welcome to Gridmancer!
# A relic of days long past, the puzzle returns!
# Your task is to collect all the coins.
# You are given special methods to help with hero task.
# hero.addRect(x, y, w, h) places a rectangle to collect coins.
# hero.removeRect(x, y) removes a previously added rectangle at the point.
# hero.navGrid is (basically) a 2-dimensional array containing "Coin" or "Wall"
# You must collect all coins under rectangles
# Rectangles cannot collide with themselves or walls
# You need to make at most 55 rectangles to beat hero level!

#hero.addRect(0, 18, 4, 2)
#hero.addRect(0, 0, 4, 3)
map = hero.navGrid

for i in range(20):
    addRect(i)


def addRect(row):
    y = row
    done = 0
    for col in map[row]:
        pos = map[row][col]
        if pos == "Coin" and done == 0:
            x = col
            w = 1
            done = 1
        elif pos == "Coin":
            w += 1
        elif pos == "Wall" and done == 1:
            done = 0
            hero.addRect(x, y, w, 1)
    if w == 20:
        hero.addRect(x, y, 20, 1)

please help

What do you mean? What is with that code?

Is that the answer I tried playing the level by link?
But I also have problems!

No, I think it is not.

I will try it again(20 chars)

what is the link(to the game)

https://codecombat.com/play/level/gridmancer-redux?

it only lets me play javascript

sorry(20 characters needed)

Can’t you press Change hero or language and select phyton?

no i am not on that level because I played by link not by level

Ok. Thanks for trying, @Jeremy_Yu! Anybody else?

But did it work did you try it?

Now I am doing that.

Did it work if it does i will delete it

i didnt did it?(20 chars)

It works. Please delete it. Thanks for help, but I want to learn the strategy myself with my own code.

did it work it failed right?

It worked the one you sent me

ok i deleted u delete yours