If i have a text file 'test.txt' containing:
1
1
1
2
2
3
I want it to print all the lines that are duplicates/matches.
So I would expect an output of
1
1
1
2
2
I was thinking something along the lines of:
But it doesn't work.
Please can someone advise?
1
1
1
2
2
3
I want it to print all the lines that are duplicates/matches.
So I would expect an output of
1
1
1
2
2
I was thinking something along the lines of:
Code:
test = open("test.txt", 'r') for x in test: for y in test: if x==y: print x print y
Please can someone advise?
Comment