Back to Freecodecamp

Step 7

curriculum/challenges/english/blocks/learn-tree-traversal-by-building-a-binary-search-tree/65c4f0b82db314d3fcc0b8e1.md

latest941 B
Original Source

--description--

Within the BinarySearchTree class, replace pass with an __init__ method and add a self parameter to this method.

--hints--

You should remove the pass keyword from the BinarySearchTree class.

js
({
  test: () => {
    const pyClassStr = runPython(
      `str(_Node(_code).find_class("BinarySearchTree"))`
    );
    const to_test = pyClassStr.split("\n");
    assert.notInclude(to_test[1], "pass");
  },
});

You should define an __init__ method and add a self parameter to this method. Remember to use the pass keyword inside the method body.

js
({ test: () => assert.match(code, /^\s{4}def\s+__init__\s*\(\s*self\s*\)\s*:/m) })

--seed--

--seed-contents--

py
class TreeNode:
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None
        
--fcc-editable-region--
class BinarySearchTree:
    pass
--fcc-editable-region--