Back to Freecodecamp

Step 5

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

latest734 B
Original Source

--description--

Inside the __init__ method, initialize the left and right attributes of the node to None. This is because when a node is first created, it doesn't have any left or right children. Remember to use the self keyword.

--hints--

You should assign None to the left attribute of the node using self.left.

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

You should assign None to the right attribute of the node using self.right.

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

--seed--

--seed-contents--

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