This might sound a little bit stupid but I have been having a hard time figuring it out. I have two text files and all I want to do is to compare each line of the first file with all of the lines of the second file. So far I just wanted to test a small part of my code which is:
for line1 in file1:
print line1
for line2 in file2:
print line2
I thought this small code would give me a line from first file followed by all the lines from the second file. But the way it works is totally different. It gives me this:
in file 1 line 1
in file 2 line 1
in file 2 line 2
in file 2 line 3
in file 1 line 2
What I expect to see:
in file 1 line 1
in file 2 line 1
in file 2 line 2
in file 2 line 3
in file 1 line 2
in file 2 line 1
in file 2 line 2
in file 2 line 3
Any idea of what I might be doing wrong here?
PLEASE NOTE: I don't want to just compare the whole lines with each other to check if they are the same or not, I need to do some string operations before so the zip and stuff like that won't help me. Thanks
Thanks in advance