← Back to challenges

Integer Digits Count

PythonHardmathnumbersloops

Instructions

Create a function that counts the integer's number of digits.

Examples

count(318) ➞ 3

count(-92563) ➞ 5

count(4666) ➞ 4

count(-314890) ➞ 6

count(654321) ➞ 6

count(638476) ➞ 6

Notes

  • Solve this without using strings.
  • Alternatively, you can solve this via a recursive approach.
  • A recursive version of this challenge can be found via this link.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Squares and Cubes