How to Count Vowels in a String in Python

def count_vowels(some_string):
    vowels = "aeiou"
    vowel_count = sum(1 for char in some_string if char.lower() in vowels)
    return vowel_count

text = "Python Programming is Awesome"
vowel_count = count_vowels(text)
print(f"The number of vowels in '{text}' is: {vowel_count}")

Output:

The number of vowels in ‘Python Programming is Awesome’ is: 9

Leave a Comment

Your email address will not be published.