sum(n>=10**i for i in range(100))
for (for example) inputs up to a googol. Or with your fix for the base case, 1 + sum(n>=10**i for i in range(1, 100))
Another cute way that hides the loop from itertools import count, takewhile
1 + len(list(takewhile(lambda x: 10**x <= n, count(1))))