I found a good script for the permutation of lists, combining and not combining list position on a tutorial and modified.
Here is the script:
`your text`
list1 = [1]
list2 = [6, 7, 8]
list3 = [9, 10, 11]
list4 = [12]
print("The original lists are : " + str(list1) +
" " + str(list2) +
" " + str(list3) +
" " + str(list4))
res = [[i, j, k, l] for i in list1
for j in list2
for k in list3
for l in list4]
print("All possible permutations are:")
for perm in res:
print(*perm)
Resulting in this:
1 6 9 12
1 6 10 12
1 6 11 12
1 7 9 12
1 7 10 12
1 7 11 12
1 8 9 12
1 8 10 12
1 8 11 12
My problem is I would also like to have the result permutated result of some list, like list 3 and list 4, adding this result to the previous one:
1 9 6 12
1 10 6 12
1 11 6 12
1 9 7 12
Etc...
Is this possible? I cant find a tutorial/solution to add this to the script.
I'm quite new on python programming. Thanks in advance.
I'm not sure what result you want to achieve. But as I understand your question, you want to create the list
resfrom the listslist1,list2,list3&list4, which should contain the following values:If that's your goal, you can easily achieve it by extending your code as follows:
Update: To delete all lines that contain duplicates, you can extend the code as follows:
By executing the code you will get the following output:
As you can see, the two lines that contained the elements
1 9 9 12were deleted from the list.