+ 1
1 22 333 4444 55555
by using while loop
6 Réponses
+ 1
for i in range(1,6):
print(' ' * (10-2*i), str(i) * i)
or
i = 1
while i < 6:
print(' ' * (10-2*i), str(i) *i)
i += 1
or (variable length)
i = 1
while i <= n:
print(' ' * (2*n-2*i), str(i) *i)
i += 1
note, this way probably wont work right for n > 9.
0
i=1 #starting index ( default 1 )
x=5 #ending index ( i<x<=9 )
while(i<=x):
print(" "*(x-i)+str(i)*i)
i+=1
this will do
😀
- 1
you need to use a while inside another while, the external one is number1 <=5 the internal one is number2>=1
because of that the external procede 5 time
the internal is executed 1 time the first time 2 time the second ecc.
also inside the second loop you print(numner1)
- 1
can u write program?
- 1
i already tried alot
- 1
thanks sunera