Way to accomplish task using list comphrehension
<p>Is there a way to accomplish the following using a <code>list comprehension</code>?  Or is there a more Pythonic way of accomplishing this?  </p>

<pre><code>count = 0
x = 'uewoiquewqoiuinkcnsjk'
for letter in x:
    if letter in ['a', 'e', 'i', 'o', 'u']:
        count += 1
</code></pre>

<p>Just trying to learn the best programming practices?</p>

<p>Since <code>in</code> generates a <code>True</code> or <code>False</code> and <code>True</code> and <code>False</code> <a href="http://legacy.python.org/dev/peps/pep-0285/" rel="nofollow">can reliably be used</a> as  <code>1</code> and <code>0</code> you can use <code>sum</code> with a generator:</p>

<pre><code>sum(c in 'aeiou' for c in x) 
</code></pre>

<p>Or filter + len:</p>

<pre><code>len(filter(lambda c: c in 'aeiou', x))
</code></pre>

<p>A great way to do the <em>opposite</em> is to use str.translate to delete characters in the string:</p>

<pre><code>&gt;&gt;&gt; x.translate(None, 'aeiou')
wqwqnkcnsjk
</code></pre>

<p>So then you can do:</p>

<pre><code>len(x)-len(x.translate(None, 'aeiou'))
</code></pre>

<p>In all cases, the answer is <code>10</code></p>

python list-comprehension