mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-04-14 07:00:51 -04:00
1.1 KiB
1.1 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 655775221059f5a20493d5d7 | Step 30 | 20 | step-30 |
--description--
After your for loop, add a print() call and pass in the following string to see the values of the variables you have created: f'Unvisited: {unvisited}\nDistances: {distances}'.
--hints--
You should print f'Unvisited: {unvisited}\nDistances: {distances}' after your for loop.
({ test: () => {
const shortest = __helpers.python.getDef(code, "shortest_path");
const {function_body} = shortest;
assert(function_body.match(/(^\s*)for.*:.*^\1print\s*\(\s*f("|')Unvisited:\s*\{\s*unvisited\s*\}\\nDistances:\s\{\s*distances\s*\}\2\s*\)/ms));
}
})
--seed--
--seed-contents--
my_graph = {
'A': [('B', 3), ('D', 1)],
'B': [('A', 3), ('C', 4)],
'C': [('B', 4), ('D', 7)],
'D': [('A', 1), ('C', 7)]
}
--fcc-editable-region--
def shortest_path(graph, start):
unvisited = []
distances = {}
for node in graph:
unvisited.append(node)
if node == start:
distances[node] = 0
else:
distances[node] = float('inf')
--fcc-editable-region--