I have a file with a list of tuples like this:
(1, 4)
(569, 39)
(49, 69)
. . .
I have this CODE, but read it all the lines in the same time, I want read just only line, for example line 1, and have the values x,y for set them in a function, then, return line 2 and take the values x, y, and do it again, and stop when the lenght of my file is done.
What can I change in the code for return the next line?
import ast
def readfile():
filename = open('file.log')
result=[]
with open('file.log', 'r') as f:
lst = [ast.literal_eval(line) for line in f.readlines()]
for t in lst:
x, y = t
for t in [(x,y) for x in t[0:] for y in t[:1]]:
print x, y
value = (x, y)
result.append(value)
return result[1:-1]
print readfile()

result.append()to crash withTypeError: append() takes exactly one argument (0 given).lst =and go right tofor t in f.readlines():