[Tutor] Comparing two different text file
Marc Tompkins
marc.tompkins at gmail.com
Wed Jul 30 02:19:00 CEST 2014
On Tue, Jul 29, 2014 at 4:13 PM, 이명교 <toll at naver.com> wrote:
> inf1 = open('first.txt')
> for line in inf1.readlines():
> list1.append(line)
So far, so good...
> list1 = line[:-1].split('\n')
...but then you do this, which wipes out list1.
> for a in list1:
> if a not in list1:
Even if you hadn't already wiped out list1, this would be a problem.
These two lines essentially say "if a is both in AND not in list1..."
There might be other issues, but fixing those will get you started.
Also: don't be afraid to add print() all over the place so you can
see what's happening!
More information about the Tutor
mailing list