+ 2
How to print diamond using for loops with '*'???
i.e. * * * * * * * * *
6 Respuestas
+ 3
n = int(input())
for i in range(1,n+1):
print((n - i)*' ' + ((2*i) - 1)*'*')
for i in range(2,n+1): print((i-1)*' ' +((n + n)-((2*i)-1))*'*')
+ 2
You have to figure out at what intervals you want them to be printed. As a result, you should see or find some sort of pattern and make conditions out of it. An example: if index % 3 == 0 print("*"). This code says every three print that out. Of course it'll be different for each row.
You will need 2 for loops. One nested in the other because you need to create a grid and think of it as printing it in coordinates.
I will stop here becuase I can go on and on and you might have questions already. So read it through, think it out a bit before you ask any questions. You'll be surprised with what you can figure out on your own with some thinking!
+ 1
thnx to u too zahra
0
i tried a lot but i was unable to figure it out but still thanks
0
i figured it out...thanks a lot !!!!!
0
Glad to hear!