Am 13.01.2021 um 22:20 schrieb Bischoop:
I want to  to display a number or an alphabet which appears mostly
consecutive in a given string or numbers or both
Examples
s= ' aabskaaabadcccc'
output: c
# c appears 4 consecutive times
  8bbakebaoa
output: b
#b appears 2 consecutive times


You can let itertools.groupy find the groups.

max((len(tuple(group)), key) for key, group in itertools.groupby(s))
# (4, 'c')
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to