everybody! I'm very new to Python and I'm trying to learn some essentials. I bumped with a task while passing online courses for beginners. The task was to create a programm, which would read a string of some letters, for example, 'aaabbbccc', and output 'a3b3c3' (another example: it could be 'abccaab', then programm should output 'a1b1c2a2b1'). I thought I found a way to deal with it using while loop, but at the end, when I add elif-construction in if else, it doesn't work: when i input my string and press enter, it just passes to the next line and seems like programm haven't started at all. I'll be very thankfull for any comment or advise about how to fix it or any alternative ideas that migth help to solve the task.
n = input()
i = 0
j = i + 1
s = 1
m = ''
while j < len(n):
if j == len(n) - 1:
s += 1
m += n[j] + str(s)
elif n[i] != n[j]:
m += n[i] + str(s)
i += 1
j += 1
s = 1
else:
i += 1
j += 1
s += 1
print(m)
if j == len(n) - 1nothing happens to j; you get a never ending loop. Add afterm += n[j] + str(s)inside that caseprint(j)to see for yourself.