Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def span(string, char):
- i = 0
- while i < len(string) and string[i] == char:
- i += 1
- return string[0:i], string[i:]
- def count_occurrences(string):
- if string:
- print(len(span(string, string[0])[0]), string[0], sep='', end='')
- count_occurrences(span(string, string[0])[1])
- else:
- print()
- count_occurrences('aaaaabbbbccccccaaaaaaa')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement