Count number of digits in an integer Dry Run in PYTHON

Count number of digits in an integer is an interactive PYTHON dry run visualizer from the While 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 number of digits in an integer Program Code

# Count digits in a number
num = int(input("Enter a number: "))
original = num
count = 0

if num == 0:
    count = 1
else:
    while num > 0:
        count += 1
        num //= 10

print(f"Number {original} has {count} digits")

View the complete While programs page.

Program Console Count number of digits in an integer Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.