title: Print 1 to N - Digits Count
body: <p>I am working on a question in a coding website and got some problem in solving it. The question is:</p>
  
  <blockquote>
    <p>Print 1 to N - Digits Count [ZOHO]</p>
    
    <p>A positive integer N is passed as the input. If we print all the
    numbers from 1 to N continuosly, the program must find the number of
    characters(digits) C printed and print the count C as the output.</p>
    
    <p>Input Format: The first line contains N.</p>
    
    <p>Output Format: The first line contains C.</p>
    
    <p>Boundary Conditions: 1 &lt;= N &lt;= 9999999</p>
    
    <p>Example Input/Output 1: Input: 2</p>
    
    <p>Output: 2</p>
    
    <p>Explanation: We print 12 and hence the total number of characters is
    2.</p>
    
    <p>Example Input/Output 2: Input: 15</p>
    
    <p>Output: 21</p>
    
    <p>Explanation: We print 123456789101112131415 and hence the total number
    of characters is 21.</p>
  </blockquote>
  
  <p>I solved the problem, but my code didn't pass all the test cases (they are hidden). This is my code:</p>
  
  <pre><code>n = int(input())
  assert 1&lt;=n&lt;=9999999
  a = [str(i) for i in range(1,n+1)]
  b = ''.join(a)
  print(len(b))
  </code></pre>
  
  <p>Is this is the right way to solve the problem or is there any other way which can be used to solve this problem?</p>