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
You can do this very simply with this syntax that someone already mentioned, but it's by far the easiest way to do it:
inputFile = open("lineNumbers.txt", "r") lines = inputFile.readlines() print (lines[0]) print (lines[2])