please code in python from typing import TextIO def clean(in_file: TextIO, out_file: TextIO) -> None: ''' in_file is a file open for reading; out_file is a file open for writing. Each line in in_file ends with a newline character. Copy each line from in_file to out_file. For any line that includes a *, do not include the first * or any following characters on that line. ''' in_file = open(in_file) # Line 1 out_file = open(out_file, 'w') # Line 2 line = in_file.readline() # Line 3 while line.strip(): # Line 4 line = in_file.readline() # Line 5 if '*' in line: # Line 6 line = line[:line.find('*')+1] + '\n' # Line 7 out_file.write(f'{line}\n') # Line 8 line = in_file.readline() # Line 9 There may be some bugs or errors in this code that prevent it from working properly. For each line, indicate: *OK* if the line is correct *REMOVE* if the line has to be removed. *CHANGE* if the line has to be changed (here, please also indicate what the line has to be changed to). # TODO: tell us what to do with each line Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 Line 9
please code in python
from typing import TextIO
def clean(in_file: TextIO, out_file: TextIO) -> None:
'''
in_file is a file open for reading; out_file is a file open for writing.
Each line in in_file ends with a newline character.
Copy each line from in_file to out_file.
For any line that includes a *, do not include the first *
or any following characters on that line.
'''
in_file = open(in_file) # Line 1
out_file = open(out_file, 'w') # Line 2
line = in_file.readline() # Line 3
while line.strip(): # Line 4
line = in_file.readline() # Line 5
if '*' in line: # Line 6
line = line[:line.find('*')+1] + '\n' # Line 7
out_file.write(f'{line}\n') # Line 8
line = in_file.readline() # Line 9
There may be some bugs or errors in this code that prevent it from working properly.
For each line, indicate:
*OK* if the line is correct
*REMOVE* if the line has to be removed.
*CHANGE* if the line has to be changed
(here, please also indicate what the line has to be changed to).
# TODO: tell us what to do with each line
Line 1
Line 2
Line 3
Line 4
Line 5
Line 6
Line 7
Line 8
Line 9

Trending now
This is a popular solution!
Step by step
Solved in 3 steps









