How to iterate across lines in two files simultaneously?

Viewed 16639

I have two files, and I want to perform some line-wise operation across both of them. (In other words, the first lines of each file correspond, as do the second, etc.) Now, I can think of a number of slightly cumbersome ways to iterate across both files simultaneously; however, this is Python, so I imagine that there is some syntactic shorthand.

In other words, is there some simple way to adapt the

for line in file:

so that it pulls data from both files simultaneously?

3 Answers
Related