Patters in python are printed using for loops. Different numeric, alphabetic or symbolic patterns can be formed using these loops by manipulating values or print statements according to the question to find the right solution.
Below is the program to print the star pattern - upward and downward pyramid at the same time to make a new design pattern.
code:
n = int(input('Enter the number of rows:'))
i = 0
while i <= n - 1:
j = 0
while j < i:
# display space
print('', end= ' ')
j += 1
k = i
while k <= n - 1:
print('*', end= ' ')
k += 1
print()
i += 1
i = n - 1
while i >= 0:
j = 0
while j < i:
print('', end= ' ')
j += 1
k = i
while k <= n - 1:
print('*', end= ' ')
k += 1
print('')
i -= 1
Output:
The Tech Platform
Comments