๐ Python Pattern Challenge — Day 40 | Number Wave Pattern
Welcome to Day 40 of the Python Pattern Challenge! ๐
Today, we're creating an interesting Number Wave Pattern using Python. This pattern starts with a complete number sequence, gradually reduces the numbers in each row, and then expands again to create a symmetrical wave-like design.
It's a simple but effective challenge to improve your understanding of loops, number sequences, 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(1, n + 1): print(" " * (i - 1), end="") print(*range(i, n + 1)) for i in range(n - 1, 0, -1): print(" " * (i - 1), end="") print(*range(i, n + 1))
๐ง How It Works
1. Creating the upper section
for i in range(1, n + 1):This loop generates the first five rows, starting from 1 and increasing the starting number in each row.
2. Managing the spacing
print(" " * (i - 1), end="")This adds leading spaces to shift each row toward the center.
3. Printing the number sequence
print(*range(i, n + 1))The range() function generates numbers from the current value of i up to 5.
4. Creating the lower section
for i in range(n - 1, 0, -1):This loop reverses the process, gradually restoring the complete number sequence.
๐ Challenge Yourself
Increase the pattern size to 7.
Replace numbers with alphabets.
Create an inverted version of this pattern.
Try implementing the same pattern using a while loop.
Take the maximum number as input from the user.
The best way to improve your Python logic is to practice small challenges and experiment with different patterns.
41 Days. 41 Patterns. Stronger Python Logic. ๐๐ฅ
Learn • Practice • Grow with CLCODING
.png)
.png)
.png)



