This post shows how to count the number of vowels in a string in Python — a common string-processing exercise for beginners.

Count vowels in a string in Python:

Explanation:
We loop through each character of the string and check if its lowercase version is one of "aeiou". We keep a running count of how many characters match.


Python Program to Count Vowels in a String

text = input("Enter a string: ")
vowels = "aeiou"
count = 0

for ch in text.lower():
    if ch in vowels:
        count += 1

print(f"Number of vowels: {count}")

Output:

Enter a string: Simple2Code
Number of vowels: 4

Build more comfort with string manipulation through daily practice on our Problem of the Day.