Question: Write a function count_unique_lines which takes as input an open file object file that supports reading and returns the number of distinct lines of file.
Write a function count_unique_lines which takes as input an open file object file that supports reading and returns the number of distinct lines of file. For instance, if names.txt consists of the following lines
ALICE BOB CAESAR BOB
and file has been obtained using open('names.txt'), then count_unique_lines(file) should evaluate to 3.
You may assume that the final character of each line is the newline character ' '. Do not attempt to use the function open or call the close method of file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
