count consecutive elements

Dan Stromberg drsalists at gmail.com
Thu Jan 14 10:47:41 EST 2021


On Wed, Jan 13, 2021 at 6:20 PM Dan Stromberg <drsalists at gmail.com> wrote:

> On Wed, Jan 13, 2021 at 5:59 PM Tim Chase <python.list at tim.thechases.com>
> wrote:
>
>> On 2021-01-13 21:20, Bischoop wrote:
>> > 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
>>
>
> I'm kind of partial to:
>
> import collections
> import typing
>
>
> def get_longest(string: str) -> typing.Tuple[int, str]:
>
I just realized this has a kinda big bug. Don't use!


More information about the Python-list mailing list