Editor

Count and Add the Digits

Programs with input · Intermediate · about 7 min

Read a whole number and print how many digits it has and the sum of those digits, as Digits: 5 and Sum of digits: 15. The number may be negative: a minus sign is not a digit. The number 0 has one digit.

The prompts inside input() are not checked, only what you print.

Example

You type:

12345

The program prints:

Digits: 5
Sum of digits: 15
n = int(input("Number: "))
# Print how many digits it has and their sum
The solution opens after your first Check.