175k views
5 votes
Write a statement that takes a variable named text_file 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.

1 Answer

5 votes

Answer:

contents = list(open_file.readlines())

Step-by-step explanation:

contents = list(open_file.readlines()) is a statement that takes a variable named text_file that contains a file object and reads its contents into a Python list of lines.

User Yann TM
by
4.4k points