Question DSA-STR-0009
MediumWhat is the output of this code?
s = "aaabbc"
out, i = "", 0
while i < len(s):
j = i
while j < len(s) and s[j] == s[i]:
j += 1
out += s[i] + str(j - i)
i = j
print(out)
- A.
aaabbc
- B.
3a2b1c
- C.
Sign up free to see the answer and a step-by-step explanation.