Learn Algorithm Design by Building a Shortest Path Algorithm - Step 21

Tell us what’s happening:

I feel like I did everything that’s asked in this step and still the code doesn’t pass. I am quite new at programming with python and english it’s not my first language so I’m for sure missing something I just don’t know what. I appreciate any advice, knowledge you have. Thank you!!!
This is the step:
Create a for loop to iterate over your graph, and append each node to the unvisited list.

Your code so far

my_graph = {
    'A': [('B', 3), ('D', 1)],
    'B': [('A', 3), ('C', 4)],
    'C': [('B', 4), ('D', 7)],
    'D': [('A', 1), ('C', 7)]
}


# User Editable Region

def shortest_path(graph, start):
    unvisited = []
    for node in graph:
       unvisited.append('A', 'B', 'C', 'D')

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36

Challenge Information:

Learn Algorithm Design by Building a Shortest Path Algorithm - Step 21

You are supposed to append the node at the current iteration. You don’t have to specify which one.
Also, remember that append can take a single argument. a_list.append(item1, item2) will raise an exception.

1 Like

Thank you!!!

1 Like

I tried all the suggestions provided here, none of them is working out for me. It’s still saying, as below: -

You should append each node to unvisited inside your for loop

Here is my code so far: -

def shortest_path(graph, start):
unvisited =
for my_graph in graph:
unvisited.append(‘A’,‘B’,‘C’,‘D’)

Please open a new topic thread for your question, thanks!

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.