Given a string, find out the highest repeated characters count in python -


i newbie python. trying solve of general programming questions. part of this, have tried many ways achieve following. example, have string

s = "abbcddeeffffcccddddggggghhhiaajjjkk" 

i want find out maximum successive occurrence of each character in given string. in above case, output should like,

a - 2 b - 2 c - 3 d - 4 e - 2 f - 4 g - 5 etc 

any appreciated, thanks!!

>>> s = "abbcddeeffffcccddddggggghhhiaajjjkk" >>> x in sorted(set(s)): ...   = 1;  ...   while x * in s: ...     += 1 ...   print x, "-", - 1 ...  - 2 b - 2 c - 3 d - 4 e - 2 f - 4 g - 5 h - 3 - 1 j - 3 k - 2 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -