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
To print line# 3,
line_number = 3 with open(filename,"r") as file: current_line = 1 for line in file: if current_line == line_number: print(file.readline()) break current_line += 1
Original author: Frank Hofmann