I\'m using a for loop to read a file, but I only want to read specific lines, say line #26 and #30. Is there any built-in feature to achieve this?
Thanks
A better and minor change for Alok Singhal's answer
fp = open("file") for i, line in enumerate(fp,1): if i == 26: # 26th line elif i == 30: # 30th line elif i > 30: break fp.close()