# This is my code and I think it is correct but still doesn't pass: indentation error
def shortest_path(graph, start):
unvisited = []
distances = {0}
for node in graph:
unvisited.append(node)
if node == start:
I am not sure when the step 23 asks "Then assign 0 to that node inside the distances dictionary.
In python I can add an item to the dictionary using a index key and assigning a value to it, right?? so inside distances I should have:
# This is my observatioin
distances = {'start': 0}
It’s not passing because you need something in the if statement.
Do not modify this line, it’s not mentioned in the instructions:
distances = {}
For the assignment it’s asking
“The node” it’s referring to is node, not start. You’ve already defined the distances dictionary, and assigned it an empty dictionary, so you don’t want to define it again.
How would you access the node key of distances and assign it 0?
Indeed I am doing something wrong I should not after three weeks with you…
# this below run ok in my editor but not into yours
def shortest_path(graph, start):
unvisited = []
distances = {}
for node in graph:
unvisited.append(node)
if node == start:
distances[node] = 0
I am getting the below erro r and trying and trying again and again :
Sorry, your code does not pass. Keep trying.
You should create an if statement that executes when node is equal to start.
# is my if statement wrong..Personally, I do not think so.
if node == start: