christmas tree program in python

Solutions on MaxInterview for christmas tree program in python by the best coders in the world

showing results for - "christmas tree program in python"
Sandeep
04 Apr 2017
1tree_height = input("Enter the tree height : ")
2tree_height = int(tree_height)
3spaces = tree_height-1
4hashes = 1
5stump_spaces = tree_height-1
6
7while tree_height != 0 :
8    for i in range(spaces):
9        print(' ', end="")
10    for i in range(hashes):
11        print('#', end="")
12    print()
13    tree_height -= 1
14    spaces -= 1
15    hashes += 2
16for i in range(stump_spaces):
17    print(' ', end="")
18print('#',end="")