title: Reaplce img value with value from list Python
body: <p>I create txt file with 4 values and save them into list [] , my problem is to replace src links in localy saved html file with values from list , but program replace only last value from list. </p>
  
  <p>Program Code:</p>
  
  <pre><code> list= []
   num_lines = sum(1 for line in open('txt.txt'))
   with open("txt.txt") as file:
      for line in file:
          list.append(line)
  
   s = open("index.html").read()
   i=0
   for i,val in enumerate(list):
    word = ''
    html = re.sub('src="(.*?)"', 'src="'+word.join(val)+'"',s,count=num_lines)
   f = open("index2.html",'w')
   f.write(html)
   f.close
  </code></pre>
  
  <p>Txt File:</p>
  
  <pre><code>value1
  value2
  value3
  value4
  </code></pre>
  
  <p>Html result :</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;body&gt;
  &lt;a href="http://simple_site"/&gt;
  &lt;img src="value4"&gt;
  
  &lt;a href="http://simple_site"/&gt;
  &lt;img src="value4"&gt;
  
  &lt;a href="http://simple_site"/&gt;
  &lt;img src="value4"&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>