Search code examples
pythonlistcombinationspython-itertools

Why is it showing combination object instead of combination.I want to print all the possible combo of all lenghts


I want to print possible combinations to a string of all lengths

import itertools

string = input()

l1 = [ ]

for i in string:
    l1.append(i)

combo = []

combo = [itertools.combinations(l1,i) for i in range(len(l1))]  #i want to resolve this line

print(combo)

Solution

  • try this

    import itertools
    string = input()
    l1 = [i for i in string ]
    
    combo = [list(itertools.combinations(l1,i)) for i in range(len(l1))] 
    print(combo)