I have this Function:
def depth(self):
if self.root == None:
return 0
left = depth(self.left)
right = depth(self.right)
if left>right:
return left+1
else:
return right+1
But when I run it, the following error pops up:
File "/Users/suryakannan/Documents/Python Programs/binaryTree.py", line 60, in depth
left = depth(self.left)
NameError: name 'depth' is not defined
So, what should I do to fix this function?
self.depth(self.lenght),self.depthsince it's inside a class