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

Tell us what’s happening:

Describe your issue in detail here.

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/ Safari/537.36

Challenge Information:

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

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.

Hello ayshabashir55, welcome to the forum!

So you made a for loop, and you are appending things to the unvisted list.
But what you are supposed to add to the list, is each node that you are looping through in the graph. Nothice how you wrote for node in graph: the node part is each node in the current iteration. That is what you have to add.

its work! Thank you for helping

1 Like

Correct Answer:
—solution removed—

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

This thread also already has a marked solution, and so no need to reply here.