Print Inverted Pyramid Pattern

Print an inverted centered pyramid of stars.

PythonBeginner
Python
# 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
*****
 ***
  *

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