[Solved] Finding repeated lines in Python [duplicate]


I assume you have read in the lines and stored them in an array

lines

Then,

set(lines)

gives you a set that contains all unique lines. If every line is unique the length of lines and set(lines) will be the same. Ergo:

if len(lines) == len(set(lines)):
      print 'all lines are unique'
   else:
      print 'not all lines are unique'

solved Finding repeated lines in Python [duplicate]