how to create total possible sub sets of a list python

The solution for “how to create total possible sub sets of a list python” can be found here. The following code will assist you in solving the problem.

# Python Program to Print
# all subsets of given size of a set
 
import itertools
 
def findsubsets(s, n):
    return list(itertools.combinations(s, n))
 
# Driver Code
s = {1, 2, 3}
n = 2
 
print(findsubsets(s, n))

Thank you for using DeclareCode; We hope you were able to resolve the issue.

More questions on [categories-list]

0
inline scripts encapsulated in