QuestionQ56

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-empty text file in the working directory?

Question Image

Explanation

readlines() returns a list containing one element for each line read from the text file. Therefore, len(d) prints the number of lines in the file.

Community Discussion

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