I have this array:
array = [1 1 2 3 5 8]
How do I get the difference between adjacent items so that I'll obtain this array:
diff = [0 1 1 2 3]
So far, this has been my attempt but I know why this doesn't work bc i and h are not really integers
array = []
diff = []
for i in array:
h = i - 1 # h is not int() here coz it's not an index
if h >= 0:
j = i.get() - h.get()
diff.append(j)
else:
pass
I'm newbie in programming, thoughts you'll share will be appreciated