Skip to content

Instantly share code, notes, and snippets.

@vaibhavgeek
Created June 3, 2016 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vaibhavgeek/5795a1256440f76a6523474458516e88 to your computer and use it in GitHub Desktop.
Save vaibhavgeek/5795a1256440f76a6523474458516e88 to your computer and use it in GitHub Desktop.
from collections import Counter
from itertools import groupby
strs=raw_input()
count = 0
answer = ''
for k, g in groupby(strs):
count = len(list(g))
if (count > 1) and (k != ' '):
answer = answer + k + str(count)
else:
answer = answer + k
print answer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment