perl -e 'print length 987654'
6
Similarly easy in Lisp with either of write-to-string, prin1-to-string, and princ-to-string. I expect python to have some such built-in function too.I consider that to be wrong - leading zeros are not part of the number and should be ignored. Using `len(str(x))` results in `2` for the input `"01"`.
The other solutions fail differently - they generates an error and stop processing.
The `len(str())` failure doesn't generate an error, and doesn't stop processing, it simply returns the wrong answer.
So, the `len` approach is wrong, the other approaches are right.