title: Python: Finding and changing elements in fixed length records
body: <p>I am very new to programming, and have hit a wall with file handling this week.  I have the following prompt: </p>
  
  <blockquote>
    <p>Fixed Length Records </p>
    
    <p>You will be passed the filename P, firstname F,
    lastname L, and a new birthday B.</p>
    
    <p>Load the fixed length record file in P, search for F,L in the first
    and change birthday to B.</p>
    
    <p>Then save the file.</p>
  </blockquote>
  
  <p>The inputs are provided:  </p>
  
  <pre><code>import sys
  P= sys.argv[1] 
  F= sys.argv[2]
  L= sys.argv[3]
  B= sys.argv[4]
  </code></pre>
  
  <p>My Code:     </p>
  
  <pre><code>file1 = open(P, 'r')
  
  data = file1.read()
  
  
  for i in range(0, len(data)):
    if F and L not in data: 
      data.append(i)
    if F and L in data: 
      data.replace(B,B)
  
  
  file1 = open(P, 'w')
  file1.write(data)
  file1.close()
  </code></pre>
  
  <p>This is obviously not working, but I am spinning wheels.  I need to figure out how to change B, but can't quite get there.  This is the output: </p>
  
  <blockquote>
    <p>Program Output</p>
    
    <p>Your program output did not match the expected output.</p>
    
    <p>Your output: </p>
    
    <p>Adam            Smith           11111985Theodore Anderson<br>
    03201990Monty           Biscuit-Barrel  10181980Adam   Smithers<br>
    10101960Ruthy           Anderson        06062010</p>
    
    <p>Expected output:</p>
    
    <p>Adam            Smith           11111985Theodore Anderson<br>
    03201990Monty          Biscuit-Barrel 10181980Adam     Smithers<br>
    00000000Ruthy          Anderson        06062010</p>
  </blockquote>
  
  <p>I can't figure out how to change the birthday to B. </p>