In this program, we will take a user input as a list and print the combination of 2 elements whose sum is 10 with the help of the below-given steps.
Combination of 2 elements:
Steps to solve the program
- Take a list as input and create an empty list.
- Import itertools.
- With the help of for loop and itertools.combinations check for combinations from the given list whose sum is 10.
- Add such combinations to the empty list.
- Print the list to see the combination of 2 elements.
Output :