Source Code:
(back to article)
import itertools # Sample list my_list = [1, 2, 3] # Get all possible combinations of the list's elements combinations = list(itertools.combinations(my_list, 2)) # Print the combinations print(combinations)
Result:
Report an issue