Finding the length of the longest repeating 1s in a string
<p>I was wondering how one can find the length of the longest repeating 1s in a string of 1s and 0s in python, taking into account the empty string. like<code>'1011110111111'</code> would return <code>6</code> and <code>''</code> would return <code>0</code>.</p>

<p>A past post suggested using regex,</p>

<p><code>max([len(i) for i in re.compile('(1+1)').findall(count)])</code></p>

<p>but it doesn't count the case for one single 1 and the empty string.</p>

<p>Just split the string using '0' as separator and find the longest item in the list:</p>

<pre><code>s = '1011110111111'
result = len(max(s.split('0')))
</code></pre>

python