Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def do_rle(s: str) -> list[tuple]:
- ans = []
- c = 1
- for i in range (1, len(s)):
- if s[i] == s[i-1]:
- c += 1
- else:
- ans.append((s[i-1], c))
- c = 1
- ans.append((s[-1], c))
- return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement