QuestionQ49

VerifiedMiscellaneous (List Comprehensions, Lambdas, Closures, I/O)

What is the expected output of the following code when the file named existing_text_file is a non-zero-length text file located in the working directory?

Question Image

Explanation

readlines() reads the file into a list of its lines, and len(spam) returns the number of elements in that list—the number of lines in the file.

Community Discussion

No comments yet. Be the first to start the discussion!