My code is to get the combination of the user's input but I want to remove the [] at the start of the output. How can I do it? And is there any way to change my output to [[1],[2],[3],[1,2]...]
?
def combination(number):
if len(number) == 0:
return [[]]
cs = []
for c in combination(number[1:]):
cs += [c, c+[number[0]]]
return cs
number = [1, 2, 3]
print(combination(number))
Currently, I am getting the following output:
[[], [1], [2], [2, 1], [3], [3, 1], [3, 2], [3, 2, 1]]