Like the title says, i need to find the difference of integers in a list by 2 and must return a list with tuples.
initial_list = [1, 2, 3, 4]
expected_output = [(1, 3), (2, 4)]
I wrote this code:
arr = [1, 2, 3, 4]
n = 2
arr1 = []
for i in range(len(arr)):
x = i + n
if x in arr:
arr1.append(x)
print(arr1)
But doesn't work... Can u help me? Thx