I want this output:
1
0 0
1 1 1
0 0
1
My code:
n=2
k = 2 * n - 2
x = 0
for i in range(0, n):
x += 1
for j in range(0, k):
print(end=" ")
k = k - 1
for j in range(0, i + 1):
if(x==2):
print(0,end=" ")
else:
print(1, end=" ")
print("\r")
k = n - 2
x = n + 2
for i in range(n, -1, -1):
x -= 1
for j in range(k, 0, -1):
print(end=" ")
k = k + 1
for j in range(0, i + 1):
if(x==2):
print(0,end=" ")
else:
print(x, end=" ")
print("\r")
For the above code I am getting output:
1
0 0
3 3 3
0 0
1
Aucun commentaire:
Enregistrer un commentaire