from itertools import combinations input = ['h', 'e', 'l', 'l', 'o'] output = sum([map(list, combinations(input, i)) for i in range(len(input) + 1)], []) print output
Standard input is empty
[[], ['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']]