Q:

Way to accomplish task using list comphrehension

Is there a way to accomplish the following using a list comprehension?  Or is there a more Pythonic way of accomplishing this?  
count = 0
x = 'uewoiquewqoiuinkcnsjk'
for letter in x:
    if letter in ['a', 'e', 'i', 'o', 'u']:
        count += 1

Just trying to learn the best programming practices?

A:

Use the combination of list_comprehension and len function.
>>> x = 'uewoiquewqoiuinkcnsjk'
>>> len([i for i in x if i in 'aeiou'])
10
>>> 

A:

Since in generates a True or False and True and False can reliably be used as  1 and 0 you can use sum with a generator:
sum(c in 'aeiou' for c in x) 

Or filter + len:
len(filter(lambda c: c in 'aeiou', x))

A great way to do the opposite is to use str.translate to delete characters in the string:
>>> x.translate(None, 'aeiou')
wqwqnkcnsjk

So then you can do:
len(x)-len(x.translate(None, 'aeiou'))

In all cases, the answer is 10

