program to print the diamond using 2*n-1 rows
input:5
outpu:
. . . . 0 . . . .
. . . 0 0 0 . . .
. . 0 0 0 0 0 . .
. 0 0 0 0 0 0 0 .
0 0 0 0 0 0 0 0 0
. 0 0 0 0 0 0 0 .
. . 0 0 0 0 0 . .
. . . 0 0 0 . . .
. . . . 0 . . . .
i want the output should be like this. i did not got the desired output by using the code which you have sent.
n = 5
for i in range(1,n):
print ('.' * (n-i) + '0' * (i*2-1) + '.' * (n-i))
for i in range(n,0,-1):
print ('.' * (n-i) + '0' * (i*2-1) + '.' * (n-i))
Comments
Leave a comment