Answer to Question #261429 in Python for anji

Question #261429
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...

* * * *
*     *
*     *
* * * *
      *
      *
* * * *
1
Expert's answer
2021-11-05T17:25:52-0400

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


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS