I want to do a function that counts the consonants in a string, so I tried to do this:
def vowel_count(foo):
count = 0
for i in foo:
if not i == 'a' and i == 'e' and i ... and i == 'O' and i == 'U':
count += 1
return count
But this is pretty ugly and tedious to do, more so with many more conditions. Is there any way to put them together?
i.lower() in "aeiou"?not a and b and cis understood as(not a) and b and c, which is quite different fromnot (a and b and c). It is pretty hard for a character to be "e" and "O" and "U" all at the same time, even if it is not "a".sum(c for k, c in collections.Counter(i.lower()) if k in 'aeiou')