a = ['a','b','c','d']
res = []
def combinations(i,comb):
    if i>=len(a):
        res.append(comb.copy())
        return
    res.append(comb.copy())
    comb.append(a[i])
    combinations(i+1,comb)
    comb.pop()
combinations(0,[])
print(res)
This gives output as: [[], ['a'], ['a', 'b'], ['a', 'b', 'c'], ['a', 'b', 'c', 'd']] what should I change to get all the possible combinations ?