Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def compress(in_str):
- comp_str= ""
- count=1
- for i in range(len(in_str)-1):
- if in_str[i] == in_str[i+1]:
- count += 1
- else:
- comp_str += in_str[i] + str(count)
- count= 1
- comp_str += in_str[i+1] + str(count)
- return comp_str
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement