with open("testt","r") as f1: list1 = f1.readlines() print(list1)list1 = set(list1)with open("test2","r") as f2: list2 = f2.readlines() print(list2)list2 = set(list2)same_data = list1.intersection(list2)print(same_data)for i in same_data: print(i.strip())