Nov-23-2020, 07:38 AM
What is the purpose of this line?
It also isn't a solution to the problem. You're supposed to insert the count in the string, not print the count. The result should be the original string with no duplicate characters in a row, and a count following each character. In their example the input is 'cooooooooooooooooolkangaroo' and the output 'c1o17l1k1a1n1g1a1r1o2'.
As for the awkward while loop, why not do this instead?
for value in z:You don't ever use value for anything and I see no reason for doing this loop.
It also isn't a solution to the problem. You're supposed to insert the count in the string, not print the count. The result should be the original string with no duplicate characters in a row, and a count following each character. In their example the input is 'cooooooooooooooooolkangaroo' and the output 'c1o17l1k1a1n1g1a1r1o2'.
As for the awkward while loop, why not do this instead?
for i in range(len(z)-1):I think this makes more sense though:
for i in range(1, len(z)):Or even better
for c in z[1:]: