Cody Bable

Generation

generate functionMon, 24 Apr 2023

read from source file one line at a time and write to target file one line at time.

# write a function to read from source file one line at a time and write to target file one line at time. def copy(source, target): source_file = open(source, 'r') target_file = open(target, 'w') for line in source_file.readlines(): target_file.write(line) source_file.close() target_file.close() copy('a.txt', 'b.txt')

Questions about programming?Chat with your personal AI assistant