N = 120

length = 1
start = 1
answer = 0

while start <= N:
    end = start * 10 - 1
    if end > N:
        end = N

    answer += (end - start + 1) * length

    start *= 10
    length += 1

print(answer)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: