counting occurrence of elements in each sequence of the list in python
<p>I have a (very big) list like the small example. I want to count the number of D in each sequence in the list and divide by the length of that sequence. (occurrence of D in each sequence).</p>

<p>small example:</p>

<pre><code>l = ['MLSLLLLDLLGLG', 'MEPPQETNRPFSTLDD', 'MVDLSVSPDVPKPAVI', 'XNLMNAIMGSDDDG', 'MDRAPTEQNDDVKLSAE']
</code></pre>

<p>do you guys know how to do that?</p>

<p>You're looking for something like:</p>

<pre><code>def fn(x):
    return x.count('D') / len(x)
results = ap(fn, l)
</code></pre>

python