- 1

if string[i] is equal to 0, why multiplies with (i+1)?

string = input() i = 0 while (i < len(string)): print(string[i] * (i+1)) i += 1

20th Aug 2022, 5:44 PM
Josué Varela
Josué Varela - avatar
2 odpowiedzi
+ 1
It depends on what you want to output. If string is cat, you will print: c aa ttt
20th Aug 2022, 5:56 PM
abpatrick catkilltsoi
abpatrick catkilltsoi - avatar
+ 1
string[i] never equal to 0. print( "Test this " * 3 )
20th Aug 2022, 6:33 PM
Jayakrishna 🇮🇳