Question: python Problem 4: compress Write a function compress which takes a string as an argument and returns a new string such that each character is

python

python Problem 4: compress Write a function compress which takes a string

Problem 4: compress Write a function compress which takes a string as an argument and returns a new string such that each character is followed by its count, and any adjacent duplicate characters are removed (replaced by the single character). You may assume the string only contains letters. Here is an example call 1 # 'c101711klainlglair1o2' 2 3 compress('cooooooooooooooooolkangaroo') compress ('aaa') # 'a3' compress("") #

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!