0
How to print a diamond shape in python
* ** *** ** *
6 Respuestas
+ 3
#There is problem in this part:
for l in range(1,4):
for j in range(1,l+1):
print('*',end="")
#this whole code will execute(same each time) in each iteration of outermost loop as it is independent of variable i taken in outer loop.
#try this for half diamond:
for i in range(4,1,-1):
for k in range(1,i-1):
print(" ",end="")
for l in range(0,4-i+1):
print('*',end="")
print(end='\n')
#my suggestion would be to take odd number of stars in each row for a better output
+ 1
show us your code to see you already tried
0
for i in range(4,1,-1):
for k in range(1,i-1):
print(" ",end="")
for l in range(1,4):
for j in range(1,l+1):
print('*',end="")
print(end='\n')
0
But this code is not working can you please tell the flaw
0
This code is just for half diamond as I was just trying but failed