I'm generating a custom combination of sub lists without using itertools.
Here's what I've come up with:
input = [[1, 2], [2, 3], [4, 3]]
output = [[1, 2, 2, 3], [1, 2, 4, 3], [2, 3, 4, 3]]
def getList():
a = [[1, 2], [2, 3], [4, 3]]
return(a)
c=[] # output list
l = len(getList())
for i in range(l):
for j in range(i+1,l):
a=getList()
a[i].extend(a[j])
c.append(a[i])
As the extend() updates the input list, I defined a function to redefine the input. Is it a recommended practice? What could be improved here?
itertools? Because usingitertoolsis recommended practice... \$\endgroup\$input()inget_List(), what would happen if the input changes? \$\endgroup\$output. i didn't mention all combinations, did i? anyways, updated. \$\endgroup\$