Digit Pattern matching
<p>I have a list:</p>

<pre><code>a = [1, 2, 4, 5, 8, 2, 4, 2, 4, 6, 7]
</code></pre>

<p>I would like to count how many times <code>2, 4</code> appear together </p>

<pre><code>( 2 at index i and 4 at index i+1). 
</code></pre>

<p>How can I do that? </p>

<p>Join the list into a string and search for <code>'24'</code>.</p>

<pre><code>&gt;&gt;&gt; a = [1, 2, 4, 5, 8, 2, 4, 2, 4, 6, 7]
&gt;&gt;&gt; ''.join(map(str, a)).count('24')
3
</code></pre>

python python-3.x indexing