8. Problem to find the combination of 2 elements from the list.

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
  1. Take a list as input and create an empty list.
  2. Import itertools.
  3. With the help of for loop and itertools.combinations check for combinations from the given list whose sum is 10.
  4. Add such combinations to the empty list.
  5. Print the list to see the combination of 2 elements.

Output :

Related Articles

Remove all duplicate elements

Squares of all even numbers

Leave a Comment