Is there a more succinct / pythonic way to do this? (counting longest seq of heads, tails in coin flips)
<p>Count the longest sequence of heads and tails in 200 coin flips.<br>
I did this - is there a niftier way to do it in python?  (without being too obfuscated)</p>

<pre><code>import random

def toss(n):
    count = [0,0]
    longest = [0,0]
    for i in xrange(n):
        coinface = random.randrange(2)
        count[coinface] += 1
        count[not coinface] = 0

        if count[coinface] &gt; longest[coinface]:
            longest[coinface] = count[coinface]      
        #print coinface, count, longest  

    print "longest sequence heads %d, tails %d" %tuple(longest)

if __name__ == '__main__':
    toss(200)
</code></pre>

<p>see <a href="http://www.rexswain.com/benford.html" rel="nofollow">this</a> for what prompted my playing</p>
