Python Program to Print (Generate) Asterisk Pattern
This program prints Asterisk like pattern made of star in Python programming language.
To generate asterisk pattern we first read value of n
from user. After reading n
we generate asterisk (*) pattern having n stars on each segment in the pattern.
Python Source Code: Asterisk Pattern
# Asterisk pattern
# Reading number of row
n = int(input('Enter the value of n: '))
for i in range(1,2*n):
for j in range(1,2*n):
if j==n or i==j or i+j==2*n:
print('*', end=' ')
else:
print(' ', end=' ')
print()
Output: Asterisk Pattern
Output of generated asterisk pattern is:
Enter the value of n: 6 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *