3. Remove all the lines that contain the character 'a' in a file and write it to another file.

 


defremove_lines_with_a(input_filename, output_filename):

with open(input_filename, 'r') as infile, open(output_filename, 'w') as outfile:

for line in infile:

if 'a' not in line:

outfile.write(line)

 

if __name__ == "__main__":

input_filename = "input.txt"

output_filename = "output.txt"

remove_lines_with_a(input_filename, output_filename)

No comments:

Post a Comment