Question: Write a function count_unique_Lines which takes an input an open file object file that supports reading and returns the number of distinct lines of Tile.
Write a function count_unique_Lines which takes an input an open file object file that supports reading and returns the number of distinct lines of Tile. For instance, if nanes.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 'n' Do not attempt to use the function open or call the close method of file In 1: def count_unique lines (file): # YOUR CODE HERE raise Not ImplementedError() In 1: import 10 assert 3 - count_unique_lines(io. StringIO ("ALICE) BOBINCAESAR BOBSn")) In [ 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
