SHARE
TWEET

Untitled

a guest Feb 19th, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. s = 'aaaabbbaaaaaccccaaa'
  2.  
  3. final = s[0] # przypisujemy zerowy znak
  4.  
  5. for i in range(1, len(s)): # iterujemy po pozostalych znakach (bez zerowego))
  6.     c = s[i]
  7.     # sprawdzamy czy ostatni znak finalnego stringa jest inny
  8.     # od znaku biezacego, jesli tak jest, to doklejamy znak biezacy
  9.     if final[-1] != c:
  10.         final += c
  11.  
  12. print(final)
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