Numbers and arithmetic · Python exercise
Count the digits in a non-negative integer, including the single digit in zero.
Read a non-negative integer and print how many digits it contains. The number 0 has one digit.
Example 1
Input
12345
Output
5
Example 2
Input
0
Output
1
Zero is written with one digit.
How testing works
Your code runs once per test case with that case's standard input. Output is compared after normalising trailing spaces and blank lines at the end. Use input() without a prompt when the exercise expects clean output.
Loading editor…
Press Run tests to execute your code against every input case. Python runs in a Web Worker in your browser.