Back to Freecodecamp

Step 4

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

latest875 B
Original Source

--description--

Inside the __init__ method, delete pass and assign the value of the key parameter to the key attribute of the node using self.key.

This means that the key attribute of the TreeNode instance will be set to the value passed during the object's creation.

--hints--

You should remove the pass statement from the __init__ method.

js
({
  test: () => {
    assert.isFalse(
      runPython(
        `_Node(_code).find_class("TreeNode").find_function("__init__").has_pass()`
      )
    );
  },
});

You should assign the value of the key parameter to the key attribute of the node using self.key.

js
({ test: () => assert.match(code, /^\s{8}self\.key\s*=\s*key/m) })

--seed--

--seed-contents--

py
--fcc-editable-region--
class TreeNode:
    def __init__(self, key):
        pass
--fcc-editable-region--