Q:

Creating sub-lists from a list

I am trying to create a list containing sub-lists in python; like, the proper subset of a set. For example, 
A = [1, 2, 3, 4]

Desired List = [[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4], [1, 2, 3], [1, 2, 4], [2, 3, 4]]

Thanks!

A:

Since it seems you only want subsets of size 2 or more:
from itertools import combinations, chain
A = range(1, 5)
list(chain(*(combinations(A, r) for r in range(2, len(A)))))
# [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4), (1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4)]

If you want all proper subsets, just change range(2, len(A)) to range(len(A)).

