Digit 9
You are given
N as input. Write a program to print the pattern of 2*N - 1 rows using an asterisk(*) as shown below.Note: There is a space after each asterisk * character.Input
The first line of input is an integer
N.Explanation
In the given example,
sample input is 4
the output should be like this...
* * * *
* *
* *
* * * *
*
*
* * * *
Source code
N = int(input())
f_line = '*' * N
f_line = ' '.join(f_line)
n = f_line
for i in range(N - 2):
n += '\n' + '*' + (' ' * (2*N - 3)) + '*'
n += '\n' + f_line
for i in range(N - 2):
n += '\n' + (' ' * (2*N - 2)) + '*'
n += '\n' + f_line
print(n)
Output
Comments
Leave a comment