打算生成一个节点,运行出错,向大佬们求助
class binaryTree():
def node(root):
return [root,[],[]]
def insert_left(root,new_branch):
t = root.pop(1)
if len(t)>1:
root.insert(1,[new_branch,t,[]])
else:
root.insert(1,[new_branch,[],[]])
return root
def insert_right(root,new_branch):
t = root.pop(2)
if len(t)>1:
root.insert(2,[new_branch,[],t])
else:
root.insert(2,[new_branch,[],[]])
return root
def get_root_val(root):
return root[0]
def seet_root_val(root,new_val):
root[0] = new_val
def get_left_val(root):
return root[1]
def get_right_child(root):
return root[2]]
打算生成一个节点
bi = binaryTree().node('a')
print(bi)
运行出错,向大佬们求助