It's not a math exercise. The problem is
stringly - find the length of the
string that conventionally represents the given number. The problem is that 0 is a special case, because we write something rather than nothing. Using len(str(n)) is the
correct, idiomatic way to solve this. Consider what happens when the problem domain expands to include negative numbers...
Notice that all the straightforward solutions the author rejects, they reject because it fails on 0. Then, with the oh-so-clever log10 solution... surprise! They special-case 0. I'm not sure what the lesson here is supposed to be.