Why am I getting a " instance has no attribute '__getitem__' " error?
- by Kevin Yusko
Here's the code:
class BinaryTree:
def __init__(self,rootObj):
self.key = rootObj
self.left = None
self.right = None
root = [self.key, self.left, self.right]
def getRootVal(root):
return root[0]
def setRootVal(newVal):
root[0] = newVal
def getLeftChild(root):
return root[1]…