+ 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.
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
+ 3
Sidar Sahin
You can check code again. I have added second and easy approach.