I have a loop like the following:
with open(file, 'r') as f:
    next(f)
    for line in f:
        print line
But I don't want to print just the current line with each iteration, I want to also print the previous line like below, but the code doesn't give me what I am looking for:
with open(file, 'r') as f:
    next(f)
    for line in f:
        previous(f)    #this does not go to the previous line
        print line
        next(f)
        print line
        next(f)
Result should be like this:
Input:
line1
line2
line3
Output:
line1
line2
line2
line3
 
    