Answer to Question #257631 in Python for GANESH

Question #257631

given an integer n as input, write a program to print a number diamond of 2*n -1 rows



 input1: 5 
 input2:4



 1 
 1 2 
 1 2 3 
 1 2 3 4 
1 2 3 4 5 
 1 2 3 4 
 1 2 3 
 1 2 
 1

 1 
 1 2 
 1 2 3 
1 2 3 4 
 1 2 3 
 1 2 
 1
1
Expert's answer
2021-10-27T10:15:26-0400
n = int(input())
for i in range(1, n):
    print(' ', end='')
    print(*range(1, i + 1))
print(*range(1, n + 1))
for i in range(n - 1, 0, -1):
    print(' ', end='')
    print(*range(1, i + 1))

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