Which of the following methods returns a list of strings, where each string…

2026

Which of the following methods returns a list of strings, where each string represents a single line from the text file?

  1. A.

    read()

  2. B.

    readline()

  3. C.

    readlines()

  4. D.

    list_read()

Attempted by 152 students.

Show answer & explanation

Correct answer: C

The readlines() method reads all lines from the file object and returns them as a list of strings. Each string in the list represents one line from the file, including the newline character. Other methods like read() return a single string for the entire content, while readline() returns only one line.

Explore the full course: Rssb Senior Computer Instructor