Learn Tree Traversal by Building a Binary Search Tree - Step 30 - Socrates says indentation is wrong

Tell us what’s happening:

Code runs correctly in the terminal, but Socrates says indentation is wrong.

I have already tried:

restarting the step
Ctrl+F5
another browser (Edge)
Incognito mode

The str method is correctly inside TreeNode.

The terminal shows TypeError: str returned non-string (type NoneType), which seems expected because str contains pass.

Thanks in advance for your help!

Your code so far


class TreeNode:

    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None
# User Editable Region
    def __str__(self):
        pass
# User Editable Region

class BinarySearchTree:

    def __init__(self):
        self.root = None

    def _insert(self, node, key):
        if node is None:
            return TreeNode(key)

        if key < node.key:
            node.left = self._insert(node.left, key)
        elif key > node.key:

            node.right = self._insert(node.right, key)
        return node

    def insert(self, key):
        self.root = self._insert(self.root, key)
        
    def _search(self, node, key):
        if node is None or node.key == key:
            return node
        if key < node.key:
            return self._search(node.left, key)
        return self._search(node.right, key)
    
    def search(self, key):
        return self._search(self.root, key)

bst = BinarySearchTree()

nodes = [50, 30, 20, 40, 70, 60, 80]

for node in nodes:
    bst.insert(node)

print('Search for 80:', bst.search(80))

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/153.0.0.0 Safari/537.36

Challenge Information:

Learn Tree Traversal by Building a Binary Search Tree - Step 30

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/learn-tree-traversal-by-building-a-binary-search-tree/65c646d4148ae3b2d1cbcac4.md at main · freeCodeCamp/freeCodeCamp · GitHub

there is currently a bug with this step, if you add a space on this blank line it will work

(it’s a bug with the regex engine in the browser…)