class tree :
def __init__(self):
self.val=0
self.right=None
self.left=None
def create_tree():
x=input()
if x==-1:
return None
root=tree()
root.val=x
print(root)
print(root.val)
print(root.right)
print(root.left)
while(True):
print ("reach1")
root.left=create_tree()
root.right=create_tree()
print("reach2")
break
return root
def main():
root=tree()
root=create_tree()
main()
Why None is not returned when x==-1 in create_tree() ?
sample output:
2 <__main__.tree object at 0x7f58cbf11128> 2 None None reach1
-1 <__main__.tree object at 0x7f58cbf11208>
-1 None None reach1
-1 != '-1'