How can i get all possible combinations of list of length n in python i have written a code for string but list i am not able to do can any one help me.
def combo(w, l):
lst = []
for i in range(len(w)):
if l == 1:
lst.append(w[i])
for c in combo(w[i+1:], l-1):
lst.append(w[i] + c)
return lst
comb=map(list,combo('12345',3))
above code is to get the combinations of string it gives correct output:
['12', '13', '14', '15', '23', '24', '25', '34', '35', '45']