I have an array a = [4,3,2,1]
What I am trying to achieve is that I need a single value on subtracting the elements in the array that is 4-3-2-1.
I tried the below this using for loop but it does not seem to work. I don't seem to get the right value on execution.
def sub_num(arr):
difference = arr[0]
n = len(arr)
print(n)
print(i)
for i in n: difference = arr[n] - arr[n-1]
return(difference)
4 - 3 - 2 - 1be-2?