fork(135) download
  1. from itertools import combinations
  2.  
  3. input = ['a', 'b', 'c', 'd']
  4.  
  5. output = sum([map(list, combinations(input, i)) for i in range(len(input) + 1)], [])
  6.  
  7. print output
Success #stdin #stdout 0.03s 44632KB
stdin
Standard input is empty
stdout
[[], ['a'], ['b'], ['c'], ['d'], ['a', 'b'], ['a', 'c'], ['a', 'd'], ['b', 'c'], ['b', 'd'], ['c', 'd'], ['a', 'b', 'c'], ['a', 'b', 'd'], ['a', 'c', 'd'], ['b', 'c', 'd'], ['a', 'b', 'c', 'd']]