Say I have N lists of size n, eg, 5 tuples of size 3:
p = [[9, 9, 9], [17, 14, 18], [14, 15, 17], [14, 15, 17], [14, 15, 15]]
How can I find the difference between indexes of the lists, for example the index 0:
17-9 = 8
14-17 = -3
14-14 = 0
14-14 = 0
then for index 1:
14-9 = 5
15-14 = 1
15-15 = 0
15-15 = 0
then index 2, 3, 4.
I need the code to be able to do this dynamically so I can change N and n at will.
Any help will be greatly appreciated.
EDIT:
I have tried this thus far:
for i in range(10):
for j, k in product(range(i+1), repeat=2):
if j!=k:continue
else:
print p[i][j]-p[i-1][j]
This code is for tuples of size 2.