Any of your three indexing operations could be the cause, but num
is definitely an empty list
, so you can't index it at all. Did you perhaps mean to append to num
itself, not to a sublist within num
(which has no inner list
s at all)?
num.append(int (between_lists(network[i],network[j])))
# ^ removed [i]
Update: Based on your comments, you want a new sublist for each run of the outer loop, so what you really wanted is:
for i in range(n):
num.append([]) # Put in new sublist
for j in range(n):
num[i].append(int(between_lists(network[i],network[j])))
return num