Advertisement
Guest User

Бгггг

a guest
Jun 4th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. cph = list(input())
  2. icph = []
  3. x, y = 0, 0
  4.  
  5. cph.append('s')
  6. for i in cph:
  7.     if i == 's':
  8.         if x > 0:
  9.             icph.append('x' + str(x))
  10.         if y > 0:
  11.             icph.append('y' + str(y))
  12.         break
  13.     elif i == 'x':
  14.         x = x + 1
  15.     elif i == 'y':
  16.         y = y + 1
  17.     elif i == 'x' and y > 0:
  18.         x = x + 1
  19.         icph.append('y' + str(y))
  20.         y = 0
  21.     elif i == 'y' and x > 0:
  22.         y = y + 1
  23.         icph.append('x' + str(x))
  24.         x = 0
  25. print(icph)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement