python list of consecutive numbers code example
Example 1: how to fill an array with consecutive numbers python
array = [x for x in range(0, 10)]
print(array)
#OUTPUT: [0, 1, 2, 3, 4, 5 6, 7, 8, 9]
Example 2: python consecutive numbers difference between
[y-x for x, y in zip(A[:-1], A[1:])]
>>> A = [1, 10, 100, 50, 40]
>>> [y-x for x, y in zip(A[:-1], A[1:])]
[9, 90, -50, -10]