hi
I have a list like L=[1,2,-3,5,12,0,-2,23,51,-10,1,68]
I have to Subtraction each item of list from other .i.e l[1]-l[0] & l[2]-l[0] & l[3]-l[0]&... and l[2]-l[1]& l[3]-l[1]&... and l[3]-[2]&...
I must arrange this Subtraction in a table.I know I must use while or for...in... to create tow loop but I am novice.
any body can help me.

<email removed>
thanks with advance.

Please do not hijack old threads with rather unrelated stuff. Start your own thread with a meaningful title, and if it's homework, show some effort first.

Edited 5 Years Ago by Narue: snipped email

when I create a list,this saved with Single Quotes .i.e so these quotes don't allow me to Subtraction list items from each others, what I must do?

Hint ...

str_list = ['1','2.4','-5.3','7']
# use list comprehension
num_list = [float(item) for item in str_list]

print(num_list)  # [1.0, 2.4, -5.3, 7.0]

hi
I want subtraction list item for example x=[1,3,-6,0] but I just want x[j]-x if j>i .i.e x[1]-x[0] , x[2]-x[0], x[3]-x[0] , x[2]-x[1] , x[3]-x[2]
I use:
for i in x:
for j in x:
if j!=i:
print j-i

bu it calculate x-x[j] moreover x[j]-x,
what i must write?
how I can save this result in new list?

I am still not quite sure what you want, but it looks like you have the right idea with nested loops. This might give you a hint how to proceed ...

q = [1, 3, -6, 0]

qq = []
for ix, x in enumerate(q):
    for iy, y in enumerate(q):
        if ix != iy:
            print( x, y)  # test
            qq.append(x - y)

print('-'*20)
print(q)
print(qq)

''' my result ...
(1, 3)
(1, -6)
(1, 0)
(3, 1)
(3, -6)
(3, 0)
(-6, 1)
(-6, 3)
(-6, 0)
(0, 1)
(0, 3)
(0, -6)
--------------------
[1, 3, -6, 0]
[-2, 7, 1, 2, 9, 3, -7, -9, -6, -1, -3, 6]
'''
Comments
good hint
This question has already been answered. Start a new discussion instead.