I understand that with two notepad documents you can do this:
notepad1 = open("C:\\User\\files\\list.txt")
notepad2 = open("C:\\User\\files\\single.txt")
for aword in notepad1:
if aword == notepad2:
print(aword, "is in both files!")
Accept this does not work? on further looking this happened:
notepad1 in notepad2
False
notepad2 in notepad1
True
in this scenario notepad2 contains a single word and notepad1 contains a list of words
I think the problem is python is not comparing every word in notepad1 with notepad2 looking for a match. If this is my problem how would i resolve it?
Aucun commentaire:
Enregistrer un commentaire