LearnPy Hub
← File Handling problems
Hard

Remove Duplicate Lines

Write the input lines (until END) to a file. Create a new file with duplicate lines removed (keep the first occurrence) and print it, then the number of lines removed.

Input

Lines, then END.

Output

Unique lines, then a count.

Sample 1

Input
a
b
a
c
b
END
Output
a
b
c
2

Sample 2

Input
x
END
Output
x
0
solution.py
Output appears here
Remove Duplicate Lines · Python practice problem · LearnPy Hub