Counting longest occurence of repeated sequence in Python
Posted
by user248237
on Stack Overflow
See other posts from Stack Overflow
or by user248237
Published on 2010-04-18T22:00:59Z
Indexed on
2010/04/18
22:03 UTC
Read the original article
Hit count: 397
What's the easiest way to count the longest consecutive repeat of a certain character in a string? For example, the longest consecutive repeat of "b" in the following string:
my_str = "abcdefgfaabbbffbbbbbbfgbb"
would be 6, since other consecutive repeats are shorter (3 and 2, respectively.) How can I do this in Python?
thanks.
© Stack Overflow or respective owner