Python Centered Star Diamond (Pattern 59)

Python Code
size = 3
for x in range(size, -(size + 1), -1):
    for y in range(abs(x), 0, -1):
        print(" ", end="")
    for z in range(abs(x), 4):
        print("*", end="")
    print()

Output:

Output of the Python Centered Star Diamond pattern
BEGINNER WALKTHROUGH

How the Centered Star Diamond works

Leading spaces and changing star counts create a centered diamond that grows and then narrows.

01

Build the rows

The outer loop crosses zero, so abs(x) decreases toward the center and increases again afterward.

02

Choose what each row prints

One inner loop prints abs(x) spaces; the next prints the matching number of stars needed for each half of the shape.

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.