+ 1

1 22 333 4444 55555

by using while loop

3rd Oct 2016, 5:40 PM
Imran Gul
Imran Gul - avatar
6 Respostas
+ 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.
3rd Oct 2016, 9:28 PM
Luke Armstrong
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 😀
11th Oct 2016, 2:28 PM
Sunera
Sunera - avatar
- 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)
3rd Oct 2016, 6:22 PM
Ernesto Salvetti
Ernesto Salvetti - avatar
- 1
can u write program?
3rd Oct 2016, 6:25 PM
Imran Gul
Imran Gul - avatar
- 1
i already tried alot
3rd Oct 2016, 6:26 PM
Imran Gul
Imran Gul - avatar
- 1
thanks sunera
11th Oct 2016, 2:29 PM
Imran Gul
Imran Gul - avatar