Python Program to Print (Generate) Inverted Pyramid Star Pattern

This python program prints (generates) inverted pyramid pattern made up of stars up to n lines.

In this python example, we first read number of row in inverted pyramid star pattern from user using built-in function input(). Since function input() returns string value, we need to convert given number to integer type using int(). And then we generate inverse pyramid pattern using loop.

Python Source Code: Inverse Pyramid Pattern


# Generating Inverse Pyramid Pattern Using Stars

row = int(input('Enter number of rows required: '))

for i in range(row,0,-1):
    for j in range(row-i):
        print(' ', end='') # printing space and staying in same line
    
    for j in range(2*i-1):
        print('*',end='') # printing * and staying in same line
    print() # printing new line

In this program print() only is used to bring control to new lines.

Output

Enter number of rows required: 10

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