Python Widening Hollow Star Pattern (Pattern 96)

Python Code
n = 5  # size=5
px = n
py = n
for x in range(1, n + 1):
    for y in range(1, n * 2):
        if (y > px and y < py):
            print(" ", end="")
        else:
            print("*", end="")
    px -= 1
    py += 1
    print()

Output:

Output of the Python Widening Hollow Star Pattern pattern
BEGINNER WALKTHROUGH

How the Widening Hollow Star Pattern works

The first row is filled with stars; later rows open a larger blank center while keeping stars at both edges.

01

Build the rows

The outer loop creates five rows across nine columns, and px and py move away from the center after each line.

02

Choose what each row prints

Positions between px and py print spaces; positions outside that interval print stars, so the hollow region widens downward.

03

Keep the output aligned

The inner print calls use end="" to keep values on the same line. The final empty print() moves to the next row.