0

SOLVED: The text file had three rows at the end without value so it returned the error.

So I'm trying to store some values from a text file into a tuple and it worked at first but then I don't know what I changed that I doesn't run now.

The code I have is as follows:

processes = []
item = 1
asins = open("asins.txt", "r+")
contenido = asins.readlines()
asins.close()
for l in contenido[1:]:
    processes.append(l.split()[-1])
    while item < len(processes):
        print(str(item), processes[item])
        item = item + 1


print (processes)

The error it throws is this one:

line 8, in id_producto.append(i.split()[-1]) IndexError: list index out of range

Thank you in advance

0 Answers0