title: Fastest way to print this in python?
body: <p>Suppose I have a text file containing this, where the number on the left says how many of the characters of the right should be there:   </p>
  
  <pre><code>2 a
  1 *
  3 $
  </code></pre>
  
  <p>How would I get this output in the fastest time?  </p>
  
  <pre><code>aa*$$$
  </code></pre>
  
  <p>This is my code, but has N^2 complexity:  </p>
  
  <pre><code>f = open('a.txt')
  for item in f:
      item2=item.split()
      num = int(item2[0])
      for i in range(num):
          line+=item2[1]
  print(line)
  f.close()
  </code></pre>