L
L
lehinas2020-08-28 10:40:09
Python
lehinas, 2020-08-28 10:40:09

Can you explain a small part of the code?

Here is the code from internet

s = input()
i = 0
count = 1
out = ''
while i< (len(s) - 1):
    if s[i] == s[i+1]:
        count += 1
    else:
        out = out + s[i] + str(count)
        count = 1
    i +=1
print(out+ s[i] + str(count)


Well, here it is subtracted from len (s) odnerka
Can you please explain in simple words, I’m just learning python and I don’t understand it, they say through the python visualizer to see I don’t understand anything
Please explain in simple words

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2020-08-28
@lehinas

Indexes start from zero.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question