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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!