Write a statement that takes a variable named file_object that contains a file object and reads its contents into a Python list of lines. Store the resulting list into a variable named file_contents.Write a statement that takes a variable named file_object that contains a file object and reads its contents into a Python list of lines. Store the resulting list into a variable named file_contents.

Respuesta :

Answer:

Answered below

Explanation:

#file is first opened and saved into file_object variable.

file_object = open('new_file.txt', 'r')

file_contents = file_object.readlines()

#the readlines() reads the contents of the file, line by line and returns a list of lines. Therefore, file_contents contains a list of lines read from file object and can be iterated over to get each line.