def print_tree(height): for i in range(height): print(' ' * (height - i - 1) + '*' * (2 * i + 1)) print(' ' * (height - 1) + '|') if __name__ == "__main__": tree_height = 5 # You can change the height of the tree here print_tree(tree_height)