Junior — Senior
Line-by-line file processing
livecode
Task condition
It is required to implement two functions: the first – process_dataset, which takes a filename and a processing function, reads the file line by line, and applies the given function to each line; the second – process_record, which transforms the received string: first converting it to lowercase, then replacing each 'o' character with `'z'.
def process_dataset(file_name, process_fn):
# TODO: Implement the function
pass
def process_record(record):
# TODO: Implement the processing function
# 1. Lowercase
# 2. 0 -> z
pass
# Test the function
process_dataset('data.txt', process_record)