boris-vlasenko

Вхождение символов в строку

Aug 25th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. string = input('string=')
  2. d = {}
  3. for x in string:
  4.     if x in d:
  5.         d[x] += 1
  6.     else:
  7.         d[x] = 1
  8. print(d)
  9. res = ''
  10. for x in sorted(d.keys()):
  11.     res +=x+str(d[x])
  12. print(res)
Advertisement
Add Comment
Please, Sign In to add comment