title: build up dictionary by replacing - python
body: <p>I want to get a code to change a certain string, then added something .</p>
  
  <p>For instance,
  (Here, target_word = "Python" , tag = i</p>
  
  <p>I want to get </p>
  
  <p><a href="https://i.stack.imgur.com/xZVsq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xZVsq.png" alt="enter image description here"></a></p>
  
  <p>But instead , I kept getting the word "Python" with a "/" ??
  <a href="https://i.stack.imgur.com/Hwese.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hwese.png" alt="enter image description here"></a></p>
  
  <p>Here is my code, at where do I do wrong ?? And actually it is my whole part of code, </p>
  
  <pre><code>def insert_tag(input_filename, output_filename, tag, target_word):
  
      output = open(output_filename, 'w')
  
      for line in open(input_filename) :
          output.write(line.replace(target_word,"&lt;"+tag+"&gt;"+target_word+"&lt;"+"/"+tag+ "&gt;" ))
      output.close()    
  print("Testing Part II")
  print("Testing insert_tag() with input_filename = 'sample1.html', output_filename = 'modified1.html', "
        + "tag = 'i', target_word = 'Python'")
  insert_tag('sample1.html', 'modified1.html', 'i', 'Python')
  print()
  </code></pre>
  
  <p>Input File :
  <a href="https://i.stack.imgur.com/DbSrV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DbSrV.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/whbsy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/whbsy.png" alt="enter image description here"></a></p>
  
  <p>Output(after coding should be ):</p>
  
  <p><a href="https://i.stack.imgur.com/RoUbA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RoUbA.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/LJDEk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LJDEk.png" alt="enter image description here"></a></p>