I'm using 2.6.2 at the moment.
I've attached a picture to go along. I'm not exactly good at explaining all of these, because I'm as confused as it is...
Anyway, I've added some additional stuff to my code to allow me to debug it better. Here's the code:
def open_file():
f = open("c:/temp/test.txt","r")
g = open("c:/temp/filter.txt","r")
line = f.readlines()
line2 = g.readlines()
# Added this to check what's in memory after
# reading the files.
print line
print '-----------'
print line2
# End add
array_size = 0
for loop in line:
# Added one print here for testing:
print 'Checking: ', loop, ' for ', line2[0]
# End add
print cmp(line[array_size],line2[0])
array_size+=1
g.close()
f.close()
open_file()
And I think I've located the problem. The output window shows these in the list that I'm supposed to look through:
['filter \n', 'lol \n', 'filter \n', 'lol \n', 'lol \n', 'filter \n', 'filter']
However, the filter.txt only has:
So, I think it's the \n that is affecting the comparisons. Is there a way to remove the \n in the list?