How to count vowels in a string with Python

1 Answer

0 votes
s = "Python programming language"

s = s.lower()

vowel_counts = {}

for vowel in "aeiou":
    count = s.count(vowel)
    vowel_counts[vowel] = count
    
print(vowel_counts)





'''
run:

{'a': 3, 'e': 1, 'i': 1, 'o': 2, 'u': 1}

'''

 



answered Oct 5, 2021 by avibootz

Related questions

1 answer 146 views
1 answer 164 views
1 answer 126 views
2 answers 173 views
1 answer 162 views
162 views asked Jul 26, 2020 by avibootz
1 answer 167 views
...