May-18-2018, 03:47 PM
This is because the iterator ( 'f' is exhausted ). During the reading from a file ( the for loop ) store the line in a list or a dictionary or a set ) so you can use it later. Or you can use f.readlines() method which will create a list and iterate over the list instead of 'f'.
data = f.readlines() for line in data: # ...