'Is there a way to subtract an element with next element in a python list? [closed]

Iam new to programming and started learning python. Iam having a list if numbers a = [1,2,3,4,5] Logic should be 1-2-3-4-5 to get the result as -13. Someone help me with the python code for this problem.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source