duplicate = [] with open("musiclist.txt", "r") as file: lines = file.readlines() for line in lines: url = line.split("---")[1] a = 0 for line2 in lines: url2 = line2.split("---")[1] if url == url2: a += 1 if a >= 2: if not line in duplicate: duplicate.append(line) else: continue for duplines in duplicate: print(duplines)