I'm trying to modify this code:
class Tree:
def __init__(self, cargo, left=None, right=None):
self.cargo = cargo
self.left = left
self.right = right
def __str__(self):
return str(self.cargo)
def print_tree_inorder(tree):
if tree is None:
return
print_tree_inorder(tree.left)
print(tree.cargo, end=" ")
print_tree_inorder(tree.right)
So that it adds parentheses around every operator and pair of operands. I just don't understand where I have to put the parentheses in this to make it work... Any help would be great please!