Python - How to count occurrences of a number inside of an object?
<p>I need to count the number of occurrences of a number in a object. Not sure how to do it.</p>

<p>I can access to the values in this way: </p>

<pre><code>&gt;&gt;&gt; formset_sample.forms[0]._raw_value('type')
&gt;&gt;&gt; '1'
&gt;&gt;&gt; formset_sample.forms[1]._raw_value('type')
&gt;&gt;&gt; '2'
&gt;&gt;&gt; formset_sample.forms[2]._raw_value('type')
&gt;&gt;&gt; '2'
</code></pre>

<p>This object has len() = 3:</p>

<pre><code>&gt;&gt;&gt; len(formset_sample.forms)
&gt;&gt;&gt; 3
</code></pre>

<p>How can I obtain the occurrences of the number 2? The number '2' have exactly two occurences in this case.</p>

<p>Some clues?</p>

<p>Best Regards,</p>
