"i understand what you are saying..lets assume i have the a list of lists...how can i make a list of lists with the differences between the values from each list of a?? – Thanos Smar 1 hour ago"
if the list is called a[0] or a doesn't make a difference, you do it the exact same way except you loop over a[0][x] .. a[1][x] ... instead of a[x] ... b[x] ....
It wouldn't be easier to have them as separate lists, it's the exact same thing. Basically you have them as separate variables already, they're just called a[0] ... a[1] and so on.
EDIT - This would be a way to do it:
>>> mylist = [[6, 6, 6], [1, 1, 1], [1, 2, 3]]
>>> mylist2 = list(mylist[0])
>>> for x in range(1, len(mylist)):
for y in range(0, len(mylist[x])):
mylist2[y] = mylist2[y] - mylist[x][y]
>>> mylist2
[4, 3, 2]
>>>
using mylist2 = list(mylist[0]) makes it a new list and not change the values of the original one.
EDIT 2:
This should be it.
>>> myList = [[10, 5, 6, 7, 8], [9, 5, 6, 7, 8], [8, 5, 6, 7, 8]]
>>> myList2 = []
>>> for x in range(0, len(myList)):
subList = []
for y in range(0, len(myList[x])-1):
subList.append(myList[x][0] - myList[x][y+1])
myList2.append(subList)
>>> myList2
[[5, 4, 3, 2], [4, 3, 2, 1], [3, 2, 1, 0]]
>>>
myList2 is a list of lists with the subtracted values of the first element of each list in myList. If this isn't it, you should be able to easily modify it to make it do what you want.
EDIT3:
Ok, so this is what you want then. I'm sure an actual good programmer could do this more elegant with generators or something. I haven't delved into that yet since I'm pretty much a beginner at this, but it works.
myList = [[10, 5, 6, 7, 8], [9, 5, 6, 7, 8], [8, 5, 6, 7, 8]]
myList2 = []
for x in range(len(myList)):
subList1 = []
for y in range(len(myList[x])):
subList2 = []
for z in range(len(myList[x])):
subList2.append(myList[x][y] - myList[x][z])
subList1.append(subList2)
myList2.append(subList1)
# - First loop goes through all lists in myList
# - Create an empty subList to append lists of subLists to
# - Second loop goes through all positions in list x of mylist
# - Create another empty subList2 to append the actual values to
# - Third loop does the same as loop 2.
# - Each value in myList from the second loop (y) gets - each value from myList
# (including itself) from the third loop (z) and appended to a subList2
# - The subList2 is appended to subList1 creating a subList of subLists
# - Finally the list of subLists is appended to myList2 for each turn of the
# first loop
This will give the resulting list of lists of lists:
myList2
[[[0, 5, 4, 3, 2], [-5, 0, -1, -2, -3], [-4, 1, 0, -1, -2], [-3, 2, 1, 0, -1], [-2, 3, 2, 1, 0]],
[[0, 4, 3, 2, 1], [-4, 0, -1, -2, -3], [-3, 1, 0, -1, -2], [-2, 2, 1, 0, -1], [-1, 3, 2, 1, 0]],
[[0, 3, 2, 1, 0], [-3, 0, -1, -2, -3], [-2, 1, 0, -1, -2], [-1, 2, 1, 0, -1], [0, 3, 2, 1, 0]]]
myList2[0][0] contains all the values of myList[0][0] compared to myList[0][x]
myList[0][1] contains all the values of myList[0][1] compared to myList[0][x]
and so on...
If you had been more explicit of what you were hoping to accomplish from the get go I'm sure one of the good programmers would have answered you too. I'm doing this because I need the practice.