Apr-21-2020, 04:59 PM
If a string is given, substitute the character with number of times that character is repeated only if the character is repeated more than three times consecutively like below
Tried like below:
Quote:Input: aaaaa Expected Output: 5Za
Input: addeeeeuyyyyy Expected OutPut: add4Zeu5Zy
Tried like below:
>>> from itertools import groupby >>> strs="aaaaa" >>> [[k, len(list(g))] for k, g in groupby(strs)] [['a', 5]] >>> python-3.x