Print Inverted Pyramid Pattern

Print an inverted centered pyramid of stars.

BeginnerTopic: Loop Programs
Back

Python Print Inverted Pyramid Pattern Program

This program helps you to learn the fundamental structure and syntax of Python programming.

Try This Code
# Program to print an inverted pyramid star pattern

rows = int(input("Enter number of rows: "))

for i in range(rows, 0, -1):
    spaces = " " * (rows - i)
    stars = "*" * (2 * i - 1)
    print(spaces + stars)
Output
Enter number of rows: 3
*****
 ***
  *

Understanding Print Inverted Pyramid Pattern

We reverse the logic of the normal pyramid, starting from the widest row and decreasing.

Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.

Table of Contents