I am working on the first problem set for CS50. I believe I understand the intent (or specific workings) of every line of code, except this one:

        path = [(None, source)] + path

What does this do? It seems to 'format' the data returned from the "solve" subroutine (path), the only subroutine that we are supposed to modify. So, can anyone tell me what this code does, with the x=[()]+x pattern?


This code is supposed to make the tuple inside the square brackets the first element of path element.

Hope this helps. If it does then please check the tickmark.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .