Count Vowels, Consonants, Digits, Spaces Dry Run in PYTHON

Count Vowels, Consonants, Digits, Spaces is an interactive PYTHON dry run visualizer from the Strings programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Count Vowels, Consonants, Digits, Spaces Program Code

# Python program to count vowels, consonants, digits, spaces
text = "Hello World 2025!"

vowels = 0
consonants = 0
digits = 0
spaces = 0

vowel_set = set('aeiou')

for char in text.lower():
    if char.isalpha():
        if char in vowel_set:
            vowels = vowels + 1
        else:
            consonants = consonants + 1
    elif char.isdigit():
        digits = digits + 1
    elif char.isspace():
        spaces = spaces + 1

print("String:", text)
print("Vowels:", vowels)
print("Consonants:", consonants)
print("Digits:", digits)
print("Spaces:", spaces)

View the complete Strings programs page.

Program Console Count Vowels, Consonants, Digits, Spaces Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.