Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You will be passed the filename P, firstname F, lastname L, and a new birthday B. Hint: Each record is at a fixed length of
You will be passed the filename P, firstname F, lastname L, and a new birthday B.
# Get the filepath from the command line import sys P- sys.argv[1] F- sys.argv[2] sys.argv[3] B- sys.argv[4] # Your Code Goes Here files open(P, 'r') recordlines - files.readline () info list [l first-index last index 40 cur-line recordlines [first-index : last-index) while ten(cur line) 0: firstname-cur lineto:16] Lastname cur line[16:32] birthdate cur line[32:40] if (firstname . strip() F) and (lastname . strip() L): birthdate-B resfirstname + Lastname + birthdate info list.append (res) first index - first index 40 last index last index +40 cur-line recordlines [first-index : last-index] files.close () files = open ( P , , w , ) for i in info list: files.write(i) files.close ) Hint: Each record is at a fixed length of 16.
Then save the file.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started