How to use 'python program to count the number of vowels in a string' in Python

Every line of 'python program to count the number of vowels in a string' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
1def count_letters(string):
2 freq, limit, i = {}, len(string), 0
3 while i < limit:
4 if string[i] in freq:
5 freq[string[i]] += 1
6 else:
7 freq[string[i]] = 1
8 i += 1
9 return freq
12def char_count(w):
13 num = 0
14 for i in xrange(len(w)):
15 if re.search(r'[a-zA-Z]', w[i]):
16 num += 1
17 return num

Related snippets