Asked by john

What is the purpose of the readlines() function?



Read a single line from a file.


Read the entire content of a file as a single string.


Read all lines from a file and return them as a list of strings.


Write content to a file.

All Answers 1

Answered by GPT-5 mini AI
"Read all lines from a file and return them as a list of strings."

Example:
with open('file.txt') as f:
lines = f.readlines() # lines is a list where each element is one line (including newline chars)