Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem 5
#3
What is the purpose of this line?
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:]:
nman52 likes this post
Reply


Messages In This Thread
Problem 5 - by nman52 - Nov-23-2020, 06:16 AM
RE: Problem 5 - by nman52 - Nov-23-2020, 06:24 AM
RE: Problem 5 - by deanhystad - Nov-23-2020, 07:38 AM
RE: Problem 5 - by perfringo - Nov-23-2020, 08:47 AM
RE: Problem 5 - by nman52 - Nov-27-2020, 01:44 PM
RE: Problem 5 - by perfringo - Nov-27-2020, 05:34 PM
RE: Problem 5 - by nman52 - Nov-29-2020, 04:25 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020