From a38ee2052e8296dace61ffa37ef935254adebc5f Mon Sep 17 00:00:00 2001 From: Zaira <33151350+zairahira@users.noreply.github.com> Date: Tue, 21 May 2024 16:35:57 +0500 Subject: [PATCH] fix(curriculum): acknowledge tracebacks in binary search tree (#54789) Co-authored-by: Ilenia <26656284+ilenia-magoni@users.noreply.github.com> --- .../65c646d4148ae3b2d1cbcac4.md | 4 +++- .../65c9ddd336596e30a4266a50.md | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65c646d4148ae3b2d1cbcac4.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65c646d4148ae3b2d1cbcac4.md index efb3b97a917..72eba965df0 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65c646d4148ae3b2d1cbcac4.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65c646d4148ae3b2d1cbcac4.md @@ -11,12 +11,14 @@ Note that, your search returns something like `80: <__main__.TreeNode object at To change that to print a useful value, define another method named `__str__` in the `TreeNode` class. It takes a single argument `self`. +After defining `__str__` you'll get an exception in the console because the `__str__` method doesn't return anything yet. You'll work on the method body in the next step. + # --hints-- You should define a method `__str__` that takes a single argument `self`. Remember to use `pass`. ```js -assert.match(code, /def\s+__str__\(\s*self\s*\)/); +assert.match(code, /^(\s+)def\s+__init__.+?^\1def\s+__str__\(\s*self\s*\)\s*:\s*\n^\1\1pass/ms) ``` diff --git a/curriculum/challenges/english/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65c9ddd336596e30a4266a50.md b/curriculum/challenges/english/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65c9ddd336596e30a4266a50.md index b0febb9360d..c6231c60f85 100644 --- a/curriculum/challenges/english/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65c9ddd336596e30a4266a50.md +++ b/curriculum/challenges/english/07-scientific-computing-with-python/learn-tree-traversal-by-building-a-binary-search-tree/65c9ddd336596e30a4266a50.md @@ -9,6 +9,8 @@ dashedName: step-31 In the body of the `__str__` method, delete `pass` and return the result of calling the `str()` function with `self.key` as the argument. This is the attribute of the current node object that stores the value associated with the node. +After returning the result, you should see the exception disappear from the console and the output should now display the value of the `key` associated with the node. + # --hints-- You should remove the `pass` keyword from the `__str__` method.