QuestionQ29

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

What output is expected from the following code when the file named zero_length_existing_file is a zero-length file in the working directory?

Question Image

Explanation

Opening an existing zero-length file succeeds. readline() returns an empty string at end-of-file, and len('') is 0, so the program prints 0.

Community Discussion

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