(Sep-07-2022, 06:33 PM)menator01 Wrote: Here is a long way of doing it. Much room for optimizing.
def compare(arg1, arg2):
list1 = []
list2 = []
lastlist = []
with open(arg1, 'r') as file:
lines = file.readlines()
for line in lines:
if ':' not in line:
list1.append(line.strip())
with open(arg2, 'r') as file2:
lines = file2.readlines()
for line in lines:
if ':' not in line:
list2.append(line.strip())
for line in list2:
if line not in list1:
lastlist.append(line)
return lastlist
print(compare('IP1.txt', 'IP2.txt'))
Output:
['192.168.0.799', '192.168.0.900', '192.168.0.1000', '192.168.0.83']
Thanks johnny but the output give me this error message what could have gone wrong?
python3 filter.py
[]