This is a MULTIPLE ANSWER question which means you are able to select one or more answers as being correct. Note that this does not necessarily mean you should select all the answers you believe are correct (NB: There are no part marks awarded for multiple answer questions). The following code is meant to open an existing text file named 'notes.txt' and print every character in that file to the screen on a separate line. However, the code currently does not work as required. [Line numbers are added for the sake of reference and should not be interpreted as part of the code.]
1 text_file = open('notes.txt', 'r')
2 for line in text_file:
3 for char in line:
4 print(char)
5 text_file.close
Which of the following describe the issue/s with this code which stop it from performing the intended function described above?
A. Line 5 should be part of the outer loop starting on line 2.
B. On line 1, the file is opened in mode 'w' which means it can only be written to and not read.
C. The outer loop (from line 2) is empty and this is not permitted in Python.
D. Instead of the call to the print function on line 4, there should be a call to the file write function.
E. It is not possible to iterate over the contents of a file with a for loop. Line 2 should be: for char in text_file, as Python treats every element of a text file as a character.
F. Both loop headers (lines 2 and 3) use the variable 'line' which is not permitted in Python.
G. The call to the print function on line 4 should not be part of the inner loop (on line 3).