Wednesday, July 31, 2019

Star tree - Method 2

Script

#!/usr/local/bin/python3.7

print()
height = int(input("Please enter the height of the tree: "))

row = 0

while row < height:
    count = 0
    while count < height - row:
        print(end = ' ')
        count = count + 1
    count = 0
    while count < 2 * row + 1:
        print(end = '*')
        count = count + 1
    print()
    row = row + 1
print()
print()


Execution


Please enter the height of the tree: 15
               *
              ***
             *****
            *******
           *********
          ***********
         *************
        ***************
       *****************
      *******************
     *********************
    ***********************
   *************************
  ***************************
 *****************************






No comments:

Post a Comment