View Single Post
Old Dec 10th, 2005, 2:51 PM   #4
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
Shove each line into a list and then access the last and second last elements in this list.
lines = []
for line in myFile:
    lines.append(line)
lastItem = lines[-1]  # -1 refers to the last item in a list
secondLastItem = lines[-2] # -2 refers to the second last item in a list.. etc.
Cerulean is offline   Reply With Quote