I need to store user objects with each key in my BST. class BSTNode represents the nodes of our tree.
Here is the code of my BST node class:
class BSTNode():
def __init__(self, key, value=None):
self.key = key
self.value = value
self.left = None
self.right = None
self.parent = None
When I try inputting usernames as keys and user objects as values
tree = BSTNode(john.username, john)
The following error gets thrown:
NameError Traceback (most recent call last)
Input In [62], in <cell line: 2>()
1 #Level 0
----> 2 tree = BSTNode(john.username, john)
NameError: name 'john' is not defined
What am I doing wrong?