Advertisement
CosmicFox33

-3.1

Nov 23rd, 2022
563
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.25 KB | None | 0 0
  1. def do_rle(s: str) -> list[tuple]:
  2.     ans = []
  3.     c = 1
  4.     for i in range (1, len(s)):
  5.         if s[i] == s[i-1]:
  6.             c += 1
  7.         else:
  8.             ans.append((s[i-1], c))
  9.             c = 1
  10.     ans.append((s[-1], c))
  11.     return ans
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement