Check Digit Count Type

Check whether a given integer is single-digit, double-digit, or multi-digit.

IntermediatePhase 1 - Level 3: Math and Number LogicExample 4 of 10
check-digit-count-type.py
1# Take number
2num = abs(int(input("Enter a number: ")))
3
4# Check digit count
5if num < 10:
6 print("Single-digit")
7elif num < 100:
8 print("Double-digit")
9else:
10 print("Multi-digit")

Output

Enter a number: 5
Single-digit

Enter a number: 45
Double-digit

Enter a number: 123
Multi-digit

What's going on

Use range checks to determine digit count.

Key Concepts:

Single-digit: 0-9 (< 10)
Double-digit: 10-99 (< 100)
Multi-digit: 100+ (>= 100)
Use abs() to handle negative numbers