Friday, July 5, 2019

Inverted triangle using stars

Script

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

print ("Enter the number of stars in the first line: ", end = "")
lines = int(input())
print("\n")

k = 2
m = 1
for i in range(1, lines):
    for j in range (1, k):
        print(end = " ")
    k = k + 1
    while m <= (2 * (lines - i) - 1):
        print("*", end = "")
        m = m + 1
    m = 1

    print()


Execution


Enter the number of stars in the first line: 25

 ***********************************************
   *********************************************
     *******************************************
       *****************************************
         ***************************************
           *************************************
             ***********************************
               *********************************
                 *******************************
                   *****************************
                     ***************************
                       *************************
                         ***********************
                           *********************
                             *******************
                               *****************
                                 ***************
                                   *************
                                     ***********
                                       *********
                                        *******
                                          *****
                                            ***
                                              *





No comments:

Post a Comment