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

Tell us what’s happening:

Hello @team, I’m struggling and stressing you over this, please help me with that

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 i in graph:
        unvisited.append('A','B','C','D')

# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (iPhone; CPU iPhone OS 15_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/120.0.6099.119 Mobile/15E148 Safari/604.1

Challenge Information:

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

You have the whole forum here to help you, please avoid tagging staff directly when you ask for help,
please avoid tagging anyone when you ask for help

1 Like

Try to describe:

  • the problem,
  • anything you don’t understand, and
  • any questions that you have.

Hi @Osei17

You should append each node to unvisited inside your for loop.

You are manually entering the strings into the for loop.

Could you use the iterator to do that for you?

Happy coding