hey guys i have a question about 2d lists in python that's my code :
results = []
with open("p100001.psv") as csvfile:
reader = csv.reader(csvfile)
for row in reader:
results.append((str(row).split("|")))
final=[[[]]]
k = 0
while k < (len(results)-7):
for i in range(1+k,7+k):
h = 0
for j in range(0,41):
final[k].insert((41*(h)+j),results[i][j])
h = h+1
k = k+1
when k=0 and code inserting final[0] everything is ok and code working but when code continue and k=1 i have face this error for final[1] : IndexError: list index out of range
finalonly has 1 element. There's nofinal[1]so how can you insert into it?