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

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
Get step-by-step solutions from verified subject matter experts
