Skip to content

TypeScript code snippet – How to find a combination of all elements in a python list?

import itertools

stuff = [1, 2, 3]
for L in range(0, len(stuff)+1):
    for subset in itertools.combinations(stuff, L):
        print(subset)
See also  Python code snippet - How to sort a list alphabetically?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.