+ 1

How to write the correct while loop

Hello. I want to crate a while loop that outputs: aaaaaaa aaaaaa aaaaa aaaa aaa aa a Instead of: a aa aaa I know how to write the second example start = ‘’ while len(start) < 50 start += ‘START’ print(start) But I can’t minus on strings, so I wonder how I could do it the other way around, starting with a line of 50 characters down to 0 characters.

7th Feb 2021, 10:29 AM
Sidar Sahin
2 RĂ©ponses
+ 5
Sidar Sahin Try this str = 'aaaaaaaaaa' l = len(str) while l > 0: for i in range(l): print(str[l - 1], end = '') print () l -= 1 https://code.sololearn.com/cEAa3ptElOX2/?ref=app
7th Feb 2021, 10:35 AM
AÍąJ
AÍąJ - avatar
+ 3
Sidar Sahin You can check code again. I have added second and easy approach.
7th Feb 2021, 10:47 AM
AÍąJ
AÍąJ - avatar