FAQ: Graph Search: Python - A Graph Search with Real Depth

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 (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 (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

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 = []
  return visited

print(dfs(None, "bees?", None))

1 Like

By looking at your screenshot, your last parameter missing a letter i instead of vis"i"ted. :joy:


Yeah, I was pretty bad about catching typos lol. Luckily that’s over with now, can’t develop a website with django and have typos lololol.


1 Like

Why creating a default value of None, if it is to change it to something else if it is None?
Just put an empty list as default value…

Don’t PUT PASS IT won’t WORK!

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.