Golden choice problem with lists

Hello every one.
I have a problem at the level golden choice in the glacier :
I am trying to do what is writing in the help, but I have a problem. I use a list to have the path, but it’s give me an error.
Here is a part of my code :

def findBest(x,y,som,path):
   findBest(x,y+1,som+goldMap[x][y+1].value,path.append((x,y+1)))

for b in range(10):
    pa=[]
    findBest(0,b,0,pa)

And the editor give me :
TypeError : Cannot read property ‘append’ of undefined
What is this problem and how can I remove it?
I have also tried with

pa=["hello"]

An other question :
Is the 0,0 in the array at the top left or bottom left?

I’ve also tried with :

findBest(x,y+1,som+goldMap[x][y+1].value,pathe+(x,y+1))

But then I have this error :
Error : Atempted to invoke bookmark for [Funktion]

1 Like

In this code, you recursively call findBest, but you pass a null value as the path argument.
path.append((x,y+1)) does not return anything.


Did you mean path instead of pathe?


Another thing: once your findBest function is called, there is no end to the recursion. You need a way to stop calling recursively once you get what you need.

1 Like