For example: [0,1,2,3] expected results [0,1], [0,2], [0,3], [1,2], [1,3], [2,3]
Asked
Active
Viewed 40 times
-5
-
2iter_tools permutations,combinations? – user1558604 Dec 16 '19 at 21:57
-
Clarify more plz. – Bassem Samir Dec 16 '19 at 21:58
-
No i need like I explained in problem body – Bassem Samir Dec 16 '19 at 22:00
-
@BassemSamir Read the docs for itertools, they're quite good IMO. – AMC Dec 16 '19 at 23:36
1 Answers
0
Use combinations from itertools
from itertools import combinations
x = combinations(lst,2)
https://docs.python.org/2/library/itertools.html#itertools.combinations

C Haworth
- 659
- 3
- 12