Given an integer N as input, write a program to print a number diamond of 2*N -1 rows.
The number of rows in the diamond is 5.
So the output should be.
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
def NuMofDiamond(N):
# loop for creating upper part of the diamond
for i in range(N):
for dim in range(0, i + 1):
print("1 ", end = "")
print()
#loop for creating loower part of the diamond
for i in range(1, N):
for dim in range(i, N):
print("1 ", end = "")
print()
N = 5
# Calling a function
NuMofDiamond(N)
Comments
Leave a comment