I don't see a problem here, and it drives me crazy. I iterate over 2 text files. Some lines in each file match, and some do not. What I am doing is looping through file1. For each line in this file, iterate over file2 and compare each item to see if they match. What happens is my loop stops after the first loop through file1. Here is my code:
while f < 50: for line in file1: for name in file2: if name == line: print 'a match was found' f+=1
The while loop happens from somewhere else, but it works fine. I just included it in context. The problem is that file1 only gives me the first line, compares it with all the βnamesβ in file2, and then stops and does not repeat the process for the next line in file1. Am I missing something obvious?
EDIT: if I put a print statement after the first for loop and comment out another for loop, it will skip the whole first file
source share