Advertisement
Josif_tepe

Untitled

Oct 19th, 2024
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. import math
  2.  
  3. def main():
  4.     s = input("Vnesi string: ")
  5.     i = 0
  6.     res = ""
  7.     while i < len(s):
  8.         cnt = 0
  9.         for j in range(i, len(s)):
  10.             if s[i] != s[j]:
  11.                 break
  12.             cnt += 1
  13.         res += str(cnt) + s[i]
  14.         i += cnt
  15.     print(res)
  16.  
  17.  
  18.  
  19. if __name__ == "__main__":
  20.     main()
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement