How can I find duplicate lines in a text file and print them?

python, text

Solution

This is pretty easy with a set:

with open('file') as f:
    seen = set()
    for line in f:
        line_lower = line.lower()
        if line_lower in seen:
            print(line)
        else:
            seen.add(line_lower)

Problem

I have a text file with some 1,200 rows. Some of them are duplicates. How could I find the duplicate lines in the file (but not worrying about case) and then print out the line's text on the screen, so I can go off and find it? I don't want to delete them or anything, just find which lines they might be.

Original source