Question: My code is as follows: (Inside of program all indentations are correct, I am returned with no errors) import sys P= sys.argv[1] F= sys.argv[2] L=

My code is as follows: (Inside of program all indentations are correct, I am returned with no errors)
import sys P= sys.argv[1] F= sys.argv[2] L= sys.argv[3] B= sys.argv[4]
# ---------------------------------------------------------------- # # Our Helper functions: # # ---------------------------------------------------------------- #Loads the file at filepath
# Returns a 2d array with the data
#
def load2dArrayFromFile(filepath): # Your code goes here: with open(filepath, 'r') as rfile: lines = rfile.read().split(' ') while '' in lines: lines.remove('') loadedArray = [line.split('|') for line in lines] return loadedArray
# Searches the 2d array 'records' for firstname, lastname.
# Returns the index of the record or -1 if no record exists
#
def findIndex(records, firstname, lastname): # Your code goes here: for line in records: if firstname == line[0] and lastname == line[1]: return records.index(line) return -1
# Sets the birthday of the record at the given index
# Returns: nothing
def setBirthday(records, index, newBirthday): # Your code goes here: line = records[index] line[2] = newBirthday records[index] = line
# Convert the 2d array back into a string
# Return the text of the 2d array
def makeTextFrom2dArray(records): # Your code goes here: writer = str() for line in records: writer += "|".join(line) + " " writer=' '+writer return writer
# ----------------------------------------------------------------
#
# Our main code body, where we call our functions.
#
# ----------------------------------------------------------------
# Load our records from the file into a 2d array records= load2dArrayFromFile(P) # Find out which index, if any, has the name we are hunting indexWeAreHunting= findIndex(records, F, L) # Set the birthday record to the one we were passed setBirthday(records, indexWeAreHunting, B) # Convert the records into a text string output= makeTextFrom2dArray(records) # Your code goes here # write the text string out to the file with open(P,'w') as wfile: wfile.write(output)
![correct, I am returned with no errors) import sys P= sys.argv[1] F=](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66efc1faa5c91_79466efc1fa49bbc.jpg)
The output appears to be correct but it is not accepted. I can't seem to find the issue.
5. 5. Challenge: variable length records Variable Length Record Load the pipe-delimited file P It is organized with 3 fields on each line: firstname lastname birthday Search for the firstname F and lastname L replacing the birthday with B Write the file back out in the same pipe-delimited format
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
