Fastest way to print this in python?
<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>

<p>You can try like this,</p>

<pre><code>f = open('a.txt')

print ''.join(int(item.split()[0]) * item.split()[1] for item in f.readlines())
</code></pre>

python