I need to make a function that returns certain lines in a file based on a list of numbers but I keep getting ValueError: Mixing iteration and read methods would lose data. Any suggestions?
with open(path) as f:
for line in f:
if i in lst:
a = f.readline()
ans += [a.strip()]
i += 1
else:
f.readline()
i += 1
i?for line in f:or.readline(), not both.