This community-built FAQ covers the “A Graph Search with Real Depth” exercise from the lesson “Graph Search: Python”.
Paths and Courses
This exercise can be found in the following Codecademy content:
FAQs on the exercise A Graph Search with Real Depth
There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
Hello, there is something wrong with instruction 1. It says to define dfs with the parameters of (graph, current_vertex, target_value, visited=None) Which i did exactly as it should be but would not let me pass the instruction, attached is a screenshot of what i had before i pressed ‘solution’. It makes me sad that this happens sometimes because it’s encouraging to get the green check of awesomeness.
here is the solutions definition of the function (for comparison)
# Build your depth-first search function below:
def dfs(graph, current_vertex, target_value, visited=None):
if visited == None:
visited = []
visited.append(current_vertex)
return visited
print(dfs(None, "bees?", None))
Have you taken the Learn Intermediate Python 3 course? It explains a gotcha about using mutable default arguments. You shouldn’t use mutable default arguments. To learn more, find the article about it in the course.