I have a loop problem - I have to read files ('f' and 'f2') and I am trying to get each line from 'f' with accession number ('acc') and find lines containing this 'acc' in file 'f2'. The loop with 'f2' is not working properly. After finding 'acc' in 'f2' it should move to next line in 'f' and start searching for 'acc' from first line2 in 'f2' but it doesn't, it seems like it starts from where it ends, are there any simple solutions to that?
f = open("test1.txt", "r")
f2 = open("test2.txt", "r")
for line in f:
acc = line[0:9]
for line2 in f2:
if acc in line2:
print line2
break
file.seek. Or just read the entire file into a list first and then use that in the iteration.fandf2. Also, some sample inputs would be nice. Just enough to demonstrate the problem.