SHARE
TWEET

Untitled

a guest Sep 21st, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. data = input() + "."
  2. l = len(data)
  3. i = 0
  4. c = 1
  5. while (i < (l - 1)):
  6.     if ((i == 0) and (data[i]) != (data [i+1])):
  7.         s = data[i]
  8.         c = 1
  9.         i += 1
  10.         print(s,c,end='',sep='')
  11.     elif ((i != (l - 2)) and (data[i-1] != data[i]) and (data[i] != data[i+1])):
  12.         s = data[i]
  13.         c = 1
  14.         i += 1
  15.         print(s,c,end='',sep='')
  16.     elif ((i != (l - 1)) and (data[i] == data[i+1])):
  17.         while (data[i] == data[i+1]):
  18.             s = data[i]
  19.             i += 1
  20.             c += 1
  21.         print(s,c,end='',sep='')
  22.         c = 1
  23.         i += 1
  24.     elif ((i == (l - 1)) and (data[i] != data[i-1])):
  25.         s = data[i]
  26.         c = 1
  27.         print(s,c,end='',sep='')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top