The first file contains the following IP addresses: 10.0.0.1 and 10.0.0.2 and the second file contains: 10.0.0.1 and 192.168.1.1. My tiny script should display the difference between file 1 and file 2. According to my example, the output should be 10.0.0.2.
file1 = input('Filename1: ')
f = open(file1,'r')
lines1 = f.readlines()
file2 = input('Filename2: ')
g = open(file2,'r')
lines2 = g.readlines()
for line1 in lines1:
for line2 in lines2:
if line1 != lines2:
print(line1)
When i run the code i get:
Filename1: l1.txt
Filename2: l2.txt
10.0.0.1
10.0.0.1
10.0.0.2
10.0.0.2
Any ideas what is wrong ?