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)
Example:
with open('file.txt') as f:
lines = f.readlines() # lines is a list where each element is one line (including newline chars)
Submit Your Answer
We prioritize human answers over AI answers.
If you are human, and you can answer this question, please submit your answer.