# Learn Algorithm Design by Building a Shortest Path Algorithm - Step 16

### Tell us what’s happening:

The error: `my_graph["B"]` should be a list of tuples where the first item in the tuple is the connected node and the second item is the distance.

I believe that’s what my graph is? Not sure what the problem is. I may be misinterpreted.

``````
/* User Editable Region */

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

/* User Editable Region */

'C': ['B', 'D'],
'D': ['A', 'C']
}

``````

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

### Challenge Information:

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

HI there! Sorry but your question is a bit unclear, please elaborate further or provide the full error message.

My bad! The full error message is:

`my_graph["B"]` should be a list of tuples where the first item in the tuple is the connected node and the second item is the distance.

I’m confused, because I thought that’s what `my_graph["B"]` already encompasses. Not exactly sure what I need to fix to match the criteria of the error.

Hello Imoh,
So our graph represent the distance between 2 letters. If you look at the first line:

``````'A': [('B', 3), ('D', 1)],
``````

This essentially means that the distance between `A` and `B` is `3`, and that the distance between `A` and `D` is `1`.

Now you have to do something similar, but then for `B` to `A` and `B` to `C`.
Do do this, we put in a tuple for each connected point and add this to the graph.
So in the first line, the tuple between `A` and `B` is `('B', 3)`. (A connects to B with a distance of 3).

So now you got to add all the tuples that connect to `B` in the list. What you have added is the tuple `('A', 'C', 'C', 4)` but you want 2 seperate tuples that show the point it connects to with it’s distance, just like you see it in the line above it.

1 Like

That makes sense! Here’s my updated code:

`'B': [('A', 3), ('C', 4)]`

However, I’m not sure which integer to put as the distance between B & A. My error also shows: `my_graph["B"] should be a list of tuples.`

Check your punctuation, quotes, brackets… commas… etc

A already shows the distance to B. The distance from B to A is the same.

The one you posted here is good. But make sure you have a comma after each list of tuples. If it still doesn’t work can you show the whole code you have now?

After adding a comma, it worked! Thank you!

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.