from itertools import permutations
lst_N_numbers = [3, 0, 8, 1, 7]
X = 2
lst = list(permutations(lst_N_numbers, X))
for i in range(len(lst)):
print(lst[i])
'''
run:
(3, 0)
(3, 8)
(3, 1)
(3, 7)
(0, 3)
(0, 8)
(0, 1)
(0, 7)
(8, 3)
(8, 0)
(8, 1)
(8, 7)
(1, 3)
(1, 0)
(1, 8)
(1, 7)
(7, 3)
(7, 0)
(7, 8)
(7, 1)
'''