class Tree
class Tree: def __init__(self, entry, branches=()): self.entry = entry for branch in branches: assert isinstance(branch, Tree) self.branches = list(branches) def __repr__(self): if self.branches: branches_str = ‘, ‘ + repr(self.branches) else: branches_str = ” return ‘Tree({0}{1})’.format(self.entry, branches_str) def __str__(self): def print_tree(t, indent=0): tree_str = ‘ ‘ * indent + str(t.entry) + “n” for b in t.branches: tree_str += print_tree(b, indent […]