Unit 2 Task 43 - Solution

Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.

Solution - Task 43: Count digits in a sale ID

← Back to task


One possible program:

sale_id = int(input("Positive ID: "))
digits = 0
remaining = sale_id

while remaining > 0:
    remaining //= 10
    digits += 1

print("Digits:", digits)