Write a function `consonantCount`, `consonant_count` or `ConsonantCount` that takes a string of English-language text and returns the number of consonants in the string.

Consonants are all letters used to write English excluding the vowels `a, e, i, o, u`.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def consonant_count(s):
	

Solutions:
def consonant_count(str):
	return sum((1 for c in str if c.isalpha() and c.lower() not in 'aeiou'))


import re

def consonant_count(s):
	return len(re.sub('[aeiou\\d\\s\\W\\_]', '', s))


import re

def consonant_count(s):
	return len(re.sub('[^b-df-hj-np-tv-z]', '', s, flags=re.I))


VOWELS = set('aeiouAEIOU')

def consonant_count(s):
	return sum((1 for a in s if a.isalpha() and a not in VOWELS))


def consonant_count(s):
	return sum((1 for x in s if 'b' <= x.lower() <= 'z' and x not in 'eiou'))


def consonant_count(s):
	return sum((1 for x in s.lower() if x.isalpha() and x not in 'aeiou'))


def consonant_count(s):
	return sum((c in 'bcdfghjklmnpqrstvwxyz' for c in s.lower()))


def consonant_count(s):
	return sum([1 for c in s if c not in 'aeiou' and c.isalpha()])


def consonant_count(s):
	return sum((x.lower() in 'bcdfghjklmnpqrstvwxyz' for x in s))


from collections import Counter

def consonant_count(str):
	return sum((c for (x, c) in Counter(str.lower()).items() if x in 'bcdfghjklmnpqrstvwxyz'))