Home

Published

- 1 min read

python find all pairs in list

img of python find all pairs in list

The solution for this is noted below

python find all pairs in list

Solution

   # importing required ibrary
import itertools


# declaring a list
lst = [2,2,2]

# creating a list of pairs of the list
ordered_list = itertools.permutations(lst,2)

print(list(ordered_list))

Try other methods by searching on the site. That is if this doesn’t work