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
Post a Comment