fork download
  1. from itertools import combinations
  2.  
  3. input = ['h', 'e', 'l', 'l', 'o']
  4.  
  5. output = sum([map(list, combinations(input, i)) for i in range(len(input) + 1)], [])
  6.  
  7. print output
Success #stdin #stdout 0.05s 63016KB
stdin
Standard input is empty
stdout
[[], ['h'], ['e'], ['l'], ['l'], ['o'], ['h', 'e'], ['h', 'l'], ['h', 'l'], ['h', 'o'], ['e', 'l'], ['e', 'l'], ['e', 'o'], ['l', 'l'], ['l', 'o'], ['l', 'o'], ['h', 'e', 'l'], ['h', 'e', 'l'], ['h', 'e', 'o'], ['h', 'l', 'l'], ['h', 'l', 'o'], ['h', 'l', 'o'], ['e', 'l', 'l'], ['e', 'l', 'o'], ['e', 'l', 'o'], ['l', 'l', 'o'], ['h', 'e', 'l', 'l'], ['h', 'e', 'l', 'o'], ['h', 'e', 'l', 'o'], ['h', 'l', 'l', 'o'], ['e', 'l', 'l', 'o'], ['h', 'e', 'l', 'l', 'o']]