Answers for "You will be passed the filename P, firstname F, lastname L, and a new birthday B. Load the fixed length record file in P, search for F,L in the first and change birthday to B. Hint: Each record is at a fixed length of 40. Then save the file."

1

You will be passed the filename P, firstname F, lastname L, and a new birthday B. Load the fixed length record file in P, search for F,L in the first and change birthday to B. Hint: Each record is at a fixed length of 40. Then save the file.

# You will be passed the filename P, firstname F, lastname L, and a new birthday B.
# Load the fixed length record file in P, search for F,L in the first and change birthday to B.
# Hint: Each record is at a fixed length of 40.
# Then save the file.
import re
file1 = open(P, 'r') 
data = file1.read() 
file1.close() 
found = re.findall(F + ' *' + L + ' *', data) 
chars = len(found[0])
beginChar = data.find(found[0])
birthday = data[beginChar + chars:beginChar + chars + 8]
data = data.replace(birthday, B)
file1 = open(P, 'w')
file1.write(data)
file1.close
Posted by: Guest on February-13-2020
1

You will be passed the filename P, firstname F, lastname L, and a new birthday B. Load the fixed length record file in P, search for F,L in the first and change birthday to B. Hint: Each record is at a fixed length of 40. Then save the file.

# You will be passed the filename P, firstname F, lastname L, and a new birthday B.
# Load the fixed length record file in P, search for F,L in the first and change birthday to B.
# Hint: Each record is at a fixed length of 40.
# Then save the file.
import re
file1 = open(P, 'r') 
data = file1.read() 
file1.close() 
found = re.findall(F + ' *' + L + ' *', data) 
chars = len(found[0])
beginChar = data.find(found[0])
birthday = data[beginChar + chars:beginChar + chars + 8]
data = data.replace(birthday, B)
file1 = open(P, 'w')
file1.write(data)
file1.close
Posted by: Guest on February-13-2020

Code answers related to "You will be passed the filename P, firstname F, lastname L, and a new birthday B. Load the fixed length record file in P, search for F,L in the first and change birthday to B. Hint: Each record is at a fixed length of 40. Then save the file."

Python Answers by Framework

Browse Popular Code Answers by Language