๐ Python Pattern Challenge — Day 46 | Hollow Diamond with Star Line Pattern
Welcome to Day 46 of the Python Pattern Challenge! ๐
Today, we're creating a beautiful Hollow Diamond with Star Line Pattern using Python.
This pattern combines diagonal star placement with a complete horizontal row of stars in the center. The upper and lower sections create a symmetrical diamond-like structure, making the design both interesting and challenging.
This exercise is perfect for improving your understanding of nested loops, conditional statements, spacing, and pattern-building logic.
๐ฏ Today's Challenge
Write a Python program to print exactly the following pattern:
๐ป Python Solution
n = 5 for i in range(n - 1): if i == 0: print(" " * (2 * (n - 1)) + "*") else: print(" " * (2 * (n - i - 1)) + "*" + " " * (4 * i - 1) + "*") print("* " * (2 * n - 1)) for i in range(n - 2, -1, -1): if i == 0: print(" " * (2 * (n - 1)) + "*") else: print(" " * (2 * (n - i - 1)) + "*" + " " * (4 * i - 1) + "*")
๐ง Understanding the Logic
1. Setting the pattern size
n = 5This determines the number of levels in the diamond pattern.
2. Creating the upper section
for i in range(n - 1):The loop creates the upper diagonal portion of the diamond.
3. Controlling the spaces
" " * (2 * (n - i - 1))This expression controls the leading spaces and positions the stars correctly.
4. Creating the hollow diamond
"*" + " " * (4 * i - 1) + "*"This places two stars at the boundaries while increasing the empty space between them.
5. Printing the middle row
print("* " * (2 * n - 1))This creates the complete horizontal line of stars in the center.
6. Creating the lower section
for i in range(n - 2, -1, -1):The reverse loop recreates the upper section in the opposite direction, completing the symmetrical pattern.
๐ Challenge Yourself
Increase the diamond size to 7.
Replace stars with numbers or alphabets.
Create a hollow diamond without the middle star line.
Try implementing the pattern using nested loops.
Make the pattern dynamic by taking input from the user.
๐ก Key Takeaway
Pattern printing is a great way to strengthen your programming fundamentals. By understanding spacing, symmetry, loops, and conditions, you can transform simple characters into creative geometric designs.
Keep experimenting, keep coding, and challenge yourself to solve a new pattern every day!






.png)




.png)
.png)


.png)
.png)
.png)

