for i in list:
j = i + 1
print i - j
This will print out -1 times the length of list
What I wanted to do is to print the difference between value i and the next in the list.
Am I clear?
Try this:
lst = [1, 2, 3, 4]
for i in xrange(1, len(lst)):
print lst[i-1] - lst[i]
Notice that in the line for i in list, i is an element of list, not an index. In the above code, i is indeed an index. Also, it's a bad idea calling a variable list (Python uses that name for something else). I renamed it to lst.