Diamond
Given an integer value
The first line of input is an integer
In the given example, the number of rows in the diamond is
5.So, the output should be
....0....
...000...
..00000..
.0000000.
000000000
.0000000.
..00000..
...000...
....0....
def diamond_shape(number):
x = 0
for row in range(1, number + 1):
for col in range (1, (number - row) + 1):
print(end = " ")
while x != (2 * row - 1):
print("0", end = "")
x = x + 1
x = 0
print()
k = 1
x = 1
for row in range(1, number):
for col in range (1, k + 1):
print(end = " ")
k = k + 1
while x <= (2 * (number - row) - 1):
print("0", end = "")
x = x + 1
x = 1
print()
number=int(input())
diamond_shape(number)
Comments
Leave a comment