I am trying to run the following program as part of my other program
n=2
array=[[[[[[['*' for col in range(6)] for col in range(n)] for col in range(n)] for col in range(n)] for row in range(n)] for row in range(n)]for row in range(n)]
possible=[[[[[[[] for col in range(n)] for col in range(n)] for col in range(n)] for row in range(n)] for row in range(n)] for row in range(n)]
possible[0][0][0][0][0][0]=[['a', 'f', 'b', 'c', 'd', 'e'], ['a', 'f', 'b', 'c', 'e', 'd'], ['a', 'f', 'b', 'd', 'c', 'e'], ['a', 'f', 'b', 'e', 'c', 'd'], ['a', 'f', 'c', 'b', 'd', 'e'], ['a', 'f', 'c', 'b', 'e', 'd'], ['a', 'f', 'd', 'b', 'c', 'e'], ['a', 'f', 'e', 'b', 'c', 'd'], ['a', 'f', 'c', 'd', 'b', 'e'], ['a', 'f', 'c', 'e', 'b', 'd'], ['a', 'f', 'd', 'c', 'b', 'e'], ['a', 'f', 'e', 'c', 'b', 'd'], ['a', 'e', 'b', 'f', 'c', 'd'], ['a', 'e', 'b', 'c', 'f', 'd'], ['a', 'e', 'c', 'f', 'b', 'd'], ['a', 'e', 'c', 'b', 'f', 'd'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e']]
array[1][0][0][0][0][0]=['a', 'b', 'f', 'd', 'e', 'c']
array[0][0][0][0][0][0]=['*', '*', 'f', 'c', 'd', '*']
r=[]
for s in range(6):
if s!=0:
if array[0][0][0][0][0][0][s]!='*':
r.append(s)
x=[]
for y in range(6):
if y!=0:
if array[1][0][0][0][0][0][y]!='*':
x.append(y)
t=list(set(x).intersection(set(r)))
for j in t:
if (array[1][0][0][0][0][0][j]!=array[0][0][0][0][0][0][j]):
for i in possible[0][0][0][0][0][0]:
if i[0]==array[1][0][0][0][0][0][0]:
possible[0][0][0][0][0][0].remove(i)
Output is
[['a', 'f', 'b', 'e', 'c', 'd'], ['a', 'f', 'e', 'b', 'c', 'd'], ['a', 'f', 'e', 'c', 'b', 'd'],
['a', 'e', 'c', 'b', 'f', 'd'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'],
['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'],
['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'],
['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'], ['f', 'a', 'b', 'c', 'd', 'e'],
['f', 'a', 'b', 'c', 'd', 'e']]
print(possible[0][0][0][0][0][0]) should not have any list starting with 'a'. I don't understand what I am doing wrong.
okay so I'm writing this code but am not sure how to put the students in order of least to greatest correct answers. The out put should be "Student 3's number of correct answers is 4" and so on.
Here's my current code:
def main():
answers = [
['A', 'B', 'A', 'C', 'C', 'D', 'E', 'E', 'A', 'D'],
['D', 'B', 'A', 'B', 'C', 'A', 'E', 'E', 'A', 'D'],
['E', 'D', 'D', 'A', 'C', 'B', 'E', 'E', 'A', 'D'],
['C', 'B', 'A', 'E', 'D', 'C', 'E', 'E', 'A', 'D'],
['A', 'B', 'D', 'C', 'C', 'D', 'E', 'E', 'A', 'D'],
['B', 'B', 'E', 'C', 'C', 'D', 'E', 'E', 'A', 'D'],
['B', 'B', 'A', 'C', 'C', 'D', 'E', 'E', 'A', 'D'],
['E', 'B', 'E', 'C', 'C', 'D', 'E', 'E', 'A', 'D']]
key = ['D', 'B', 'D', 'C', 'C', 'D', 'A', 'E', 'A', 'D']
for i in range(len(answers)):
correctCount = 0
for j in range(len(answers[i])):
if answers[i][j] == key[j]:
correctCount +=1
print("Student", i, "'s correct count is", correctCount)
main()
I think is best you split the problem in steps:
Determine the number of correct answers
Sort the output
Given the previous steps, you could do the following:
answers = [
['A', 'B', 'A', 'C', 'C', 'D', 'E', 'E', 'A', 'D'],
['D', 'B', 'A', 'B', 'C', 'A', 'E', 'E', 'A', 'D'],
['E', 'D', 'D', 'A', 'C', 'B', 'E', 'E', 'A', 'D'],
['C', 'B', 'A', 'E', 'D', 'C', 'E', 'E', 'A', 'D'],
['A', 'B', 'D', 'C', 'C', 'D', 'E', 'E', 'A', 'D'],
['B', 'B', 'E', 'C', 'C', 'D', 'E', 'E', 'A', 'D'],
['B', 'B', 'A', 'C', 'C', 'D', 'E', 'E', 'A', 'D'],
['E', 'B', 'E', 'C', 'C', 'D', 'E', 'E', 'A', 'D']]
def number_of_correct_answers(answers, golden=['D', 'B', 'D', 'C', 'C', 'D', 'A', 'E', 'A', 'D']):
"""Return the number of correct answers given a gold standard"""
return sum(g == a for g, a in zip(golden, answers))
for student_answer in sorted(answers, key=number_of_correct_answers, reverse=True): # the best come first
print(student_answer, 'Number of correct', number_of_correct_answers(student_answer))
Output
['A', 'B', 'D', 'C', 'C', 'D', 'E', 'E', 'A', 'D'] Number of correct 8
['A', 'B', 'A', 'C', 'C', 'D', 'E', 'E', 'A', 'D'] Number of correct 7
['B', 'B', 'E', 'C', 'C', 'D', 'E', 'E', 'A', 'D'] Number of correct 7
['B', 'B', 'A', 'C', 'C', 'D', 'E', 'E', 'A', 'D'] Number of correct 7
['E', 'B', 'E', 'C', 'C', 'D', 'E', 'E', 'A', 'D'] Number of correct 7
['D', 'B', 'A', 'B', 'C', 'A', 'E', 'E', 'A', 'D'] Number of correct 6
['E', 'D', 'D', 'A', 'C', 'B', 'E', 'E', 'A', 'D'] Number of correct 5
['C', 'B', 'A', 'E', 'D', 'C', 'E', 'E', 'A', 'D'] Number of correct 4
The key of the functionaly above relies on the functions: sum and sorted. In the example above the better students come first, if you want the other way around just remove the reverse=True parameter.
See:
Sorting - HOWTO
I have a list of people and I want to make all combinations of their teams (of 3) with each other.
list_of_ppl = ['A','B','C','D','E','F']
What i need is:
>>> [['A','B','C'],['D','E','F']]
>>> [['A','B','D'],['C','E','F']]
>>> [['A','B','E'],['C','D','F']]
>>> [['A','B','F'],['C','D','E']]
>>> [['A','C','E'],['B','D','F']]
>>> and so on...
Edit: The len(list_of_ppl) can be greater than 6 and can be a number that is not divisible by 3. I only want teams of 3
For eg:
list_of_ppl = ['A','B','C','D','E','F','G']
>>> [['A','B','C'],['D','E','F'],['G']]
>>> [['A','B','D'],['C','E','G'],['F']]
>>> [['A','B','D'],['C','F','G'],['E']]
>>> [['A','B','F'],['C','E','G'],['D']]
>>> [['A','E','G'],['B','D','F'],['C']]
>>> and so on...
You can use a recursive function to keep getting a combination of 3 from the remaining list of people until the list is exhausted:
from itertools import combinations
def get_teams(list_of_ppl, size=3):
if len(list_of_ppl) > size:
for team in combinations(list_of_ppl, size):
for teams in get_teams(list(set(list_of_ppl) - set(team))):
yield [list(team), *teams]
else:
yield [list_of_ppl]
for team in get_teams(list_of_ppl):
print(team)
so that with list_of_ppl = ['A','B','C','D','E','F'], this outputs:
[['A', 'B', 'C'], ['F', 'E', 'D']]
[['A', 'B', 'D'], ['C', 'F', 'E']]
[['A', 'B', 'E'], ['C', 'F', 'D']]
[['A', 'B', 'F'], ['C', 'E', 'D']]
[['A', 'C', 'D'], ['F', 'B', 'E']]
[['A', 'C', 'E'], ['F', 'B', 'D']]
[['A', 'C', 'F'], ['B', 'E', 'D']]
[['A', 'D', 'E'], ['C', 'B', 'F']]
[['A', 'D', 'F'], ['C', 'B', 'E']]
[['A', 'E', 'F'], ['C', 'B', 'D']]
[['B', 'C', 'D'], ['E', 'F', 'A']]
[['B', 'C', 'E'], ['F', 'A', 'D']]
[['B', 'C', 'F'], ['E', 'A', 'D']]
[['B', 'D', 'E'], ['C', 'F', 'A']]
[['B', 'D', 'F'], ['C', 'A', 'E']]
[['B', 'E', 'F'], ['C', 'A', 'D']]
[['C', 'D', 'E'], ['F', 'B', 'A']]
[['C', 'D', 'F'], ['E', 'B', 'A']]
[['C', 'E', 'F'], ['B', 'A', 'D']]
[['D', 'E', 'F'], ['C', 'B', 'A']]
or with a list_of_ppl whose length is not divisible by 3 such as list_of_ppl = ['A','B','C','D','E','F','G'], this outputs:
[['A', 'B', 'C'], ['E', 'G', 'F'], ['D']]
[['A', 'B', 'C'], ['E', 'G', 'D'], ['F']]
[['A', 'B', 'C'], ['E', 'F', 'D'], ['G']]
[['A', 'B', 'C'], ['G', 'F', 'D'], ['E']]
[['A', 'B', 'D'], ['E', 'C', 'G'], ['F']]
[['A', 'B', 'D'], ['E', 'C', 'F'], ['G']]
[['A', 'B', 'D'], ['E', 'G', 'F'], ['C']]
[['A', 'B', 'D'], ['C', 'G', 'F'], ['E']]
[['A', 'B', 'E'], ['C', 'G', 'F'], ['D']]
[['A', 'B', 'E'], ['C', 'G', 'D'], ['F']]
[['A', 'B', 'E'], ['C', 'F', 'D'], ['G']]
[['A', 'B', 'E'], ['G', 'F', 'D'], ['C']]
[['A', 'B', 'F'], ['E', 'C', 'G'], ['D']]
[['A', 'B', 'F'], ['E', 'C', 'D'], ['G']]
[['A', 'B', 'F'], ['E', 'G', 'D'], ['C']]
[['A', 'B', 'F'], ['C', 'G', 'D'], ['E']]
[['A', 'B', 'G'], ['E', 'C', 'F'], ['D']]
[['A', 'B', 'G'], ['E', 'C', 'D'], ['F']]
[['A', 'B', 'G'], ['E', 'F', 'D'], ['C']]
[['A', 'B', 'G'], ['C', 'F', 'D'], ['E']]
[['A', 'C', 'D'], ['B', 'E', 'G'], ['F']]
[['A', 'C', 'D'], ['B', 'E', 'F'], ['G']]
[['A', 'C', 'D'], ['B', 'G', 'F'], ['E']]
[['A', 'C', 'D'], ['E', 'G', 'F'], ['B']]
[['A', 'C', 'E'], ['B', 'G', 'F'], ['D']]
[['A', 'C', 'E'], ['B', 'G', 'D'], ['F']]
[['A', 'C', 'E'], ['B', 'F', 'D'], ['G']]
[['A', 'C', 'E'], ['G', 'F', 'D'], ['B']]
[['A', 'C', 'F'], ['B', 'E', 'G'], ['D']]
[['A', 'C', 'F'], ['B', 'E', 'D'], ['G']]
[['A', 'C', 'F'], ['B', 'G', 'D'], ['E']]
[['A', 'C', 'F'], ['E', 'G', 'D'], ['B']]
[['A', 'C', 'G'], ['B', 'E', 'F'], ['D']]
[['A', 'C', 'G'], ['B', 'E', 'D'], ['F']]
[['A', 'C', 'G'], ['B', 'F', 'D'], ['E']]
[['A', 'C', 'G'], ['E', 'F', 'D'], ['B']]
[['A', 'D', 'E'], ['B', 'C', 'G'], ['F']]
[['A', 'D', 'E'], ['B', 'C', 'F'], ['G']]
[['A', 'D', 'E'], ['B', 'G', 'F'], ['C']]
[['A', 'D', 'E'], ['C', 'G', 'F'], ['B']]
[['A', 'D', 'F'], ['B', 'E', 'C'], ['G']]
[['A', 'D', 'F'], ['B', 'E', 'G'], ['C']]
[['A', 'D', 'F'], ['B', 'C', 'G'], ['E']]
[['A', 'D', 'F'], ['E', 'C', 'G'], ['B']]
[['A', 'D', 'G'], ['B', 'E', 'C'], ['F']]
[['A', 'D', 'G'], ['B', 'E', 'F'], ['C']]
[['A', 'D', 'G'], ['B', 'C', 'F'], ['E']]
[['A', 'D', 'G'], ['E', 'C', 'F'], ['B']]
[['A', 'E', 'F'], ['B', 'C', 'G'], ['D']]
[['A', 'E', 'F'], ['B', 'C', 'D'], ['G']]
[['A', 'E', 'F'], ['B', 'G', 'D'], ['C']]
[['A', 'E', 'F'], ['C', 'G', 'D'], ['B']]
[['A', 'E', 'G'], ['B', 'C', 'F'], ['D']]
[['A', 'E', 'G'], ['B', 'C', 'D'], ['F']]
[['A', 'E', 'G'], ['B', 'F', 'D'], ['C']]
[['A', 'E', 'G'], ['C', 'F', 'D'], ['B']]
[['A', 'F', 'G'], ['B', 'E', 'C'], ['D']]
[['A', 'F', 'G'], ['B', 'E', 'D'], ['C']]
[['A', 'F', 'G'], ['B', 'C', 'D'], ['E']]
[['A', 'F', 'G'], ['E', 'C', 'D'], ['B']]
[['B', 'C', 'D'], ['E', 'A', 'G'], ['F']]
[['B', 'C', 'D'], ['E', 'A', 'F'], ['G']]
[['B', 'C', 'D'], ['E', 'G', 'F'], ['A']]
[['B', 'C', 'D'], ['A', 'G', 'F'], ['E']]
[['B', 'C', 'E'], ['A', 'G', 'F'], ['D']]
[['B', 'C', 'E'], ['A', 'G', 'D'], ['F']]
[['B', 'C', 'E'], ['A', 'F', 'D'], ['G']]
[['B', 'C', 'E'], ['G', 'F', 'D'], ['A']]
[['B', 'C', 'F'], ['E', 'A', 'G'], ['D']]
[['B', 'C', 'F'], ['E', 'A', 'D'], ['G']]
[['B', 'C', 'F'], ['E', 'G', 'D'], ['A']]
[['B', 'C', 'F'], ['A', 'G', 'D'], ['E']]
[['B', 'C', 'G'], ['E', 'A', 'F'], ['D']]
[['B', 'C', 'G'], ['E', 'A', 'D'], ['F']]
[['B', 'C', 'G'], ['E', 'F', 'D'], ['A']]
[['B', 'C', 'G'], ['A', 'F', 'D'], ['E']]
[['B', 'D', 'E'], ['C', 'A', 'G'], ['F']]
[['B', 'D', 'E'], ['C', 'A', 'F'], ['G']]
[['B', 'D', 'E'], ['C', 'G', 'F'], ['A']]
[['B', 'D', 'E'], ['A', 'G', 'F'], ['C']]
[['B', 'D', 'F'], ['E', 'C', 'A'], ['G']]
[['B', 'D', 'F'], ['E', 'C', 'G'], ['A']]
[['B', 'D', 'F'], ['E', 'A', 'G'], ['C']]
[['B', 'D', 'F'], ['C', 'A', 'G'], ['E']]
[['B', 'D', 'G'], ['E', 'C', 'A'], ['F']]
[['B', 'D', 'G'], ['E', 'C', 'F'], ['A']]
[['B', 'D', 'G'], ['E', 'A', 'F'], ['C']]
[['B', 'D', 'G'], ['C', 'A', 'F'], ['E']]
[['B', 'E', 'F'], ['C', 'A', 'G'], ['D']]
[['B', 'E', 'F'], ['C', 'A', 'D'], ['G']]
[['B', 'E', 'F'], ['C', 'G', 'D'], ['A']]
[['B', 'E', 'F'], ['A', 'G', 'D'], ['C']]
[['B', 'E', 'G'], ['C', 'A', 'F'], ['D']]
[['B', 'E', 'G'], ['C', 'A', 'D'], ['F']]
[['B', 'E', 'G'], ['C', 'F', 'D'], ['A']]
[['B', 'E', 'G'], ['A', 'F', 'D'], ['C']]
[['B', 'F', 'G'], ['E', 'C', 'A'], ['D']]
[['B', 'F', 'G'], ['E', 'C', 'D'], ['A']]
[['B', 'F', 'G'], ['E', 'A', 'D'], ['C']]
[['B', 'F', 'G'], ['C', 'A', 'D'], ['E']]
[['C', 'D', 'E'], ['B', 'A', 'G'], ['F']]
[['C', 'D', 'E'], ['B', 'A', 'F'], ['G']]
[['C', 'D', 'E'], ['B', 'G', 'F'], ['A']]
[['C', 'D', 'E'], ['A', 'G', 'F'], ['B']]
[['C', 'D', 'F'], ['B', 'E', 'A'], ['G']]
[['C', 'D', 'F'], ['B', 'E', 'G'], ['A']]
[['C', 'D', 'F'], ['B', 'A', 'G'], ['E']]
[['C', 'D', 'F'], ['E', 'A', 'G'], ['B']]
[['C', 'D', 'G'], ['B', 'E', 'A'], ['F']]
[['C', 'D', 'G'], ['B', 'E', 'F'], ['A']]
[['C', 'D', 'G'], ['B', 'A', 'F'], ['E']]
[['C', 'D', 'G'], ['E', 'A', 'F'], ['B']]
[['C', 'E', 'F'], ['B', 'A', 'G'], ['D']]
[['C', 'E', 'F'], ['B', 'A', 'D'], ['G']]
[['C', 'E', 'F'], ['B', 'G', 'D'], ['A']]
[['C', 'E', 'F'], ['A', 'G', 'D'], ['B']]
[['C', 'E', 'G'], ['B', 'A', 'F'], ['D']]
[['C', 'E', 'G'], ['B', 'A', 'D'], ['F']]
[['C', 'E', 'G'], ['B', 'F', 'D'], ['A']]
[['C', 'E', 'G'], ['A', 'F', 'D'], ['B']]
[['C', 'F', 'G'], ['B', 'E', 'A'], ['D']]
[['C', 'F', 'G'], ['B', 'E', 'D'], ['A']]
[['C', 'F', 'G'], ['B', 'A', 'D'], ['E']]
[['C', 'F', 'G'], ['E', 'A', 'D'], ['B']]
[['D', 'E', 'F'], ['B', 'C', 'A'], ['G']]
[['D', 'E', 'F'], ['B', 'C', 'G'], ['A']]
[['D', 'E', 'F'], ['B', 'A', 'G'], ['C']]
[['D', 'E', 'F'], ['C', 'A', 'G'], ['B']]
[['D', 'E', 'G'], ['B', 'C', 'A'], ['F']]
[['D', 'E', 'G'], ['B', 'C', 'F'], ['A']]
[['D', 'E', 'G'], ['B', 'A', 'F'], ['C']]
[['D', 'E', 'G'], ['C', 'A', 'F'], ['B']]
[['D', 'F', 'G'], ['B', 'E', 'C'], ['A']]
[['D', 'F', 'G'], ['B', 'E', 'A'], ['C']]
[['D', 'F', 'G'], ['B', 'C', 'A'], ['E']]
[['D', 'F', 'G'], ['E', 'C', 'A'], ['B']]
[['E', 'F', 'G'], ['B', 'C', 'A'], ['D']]
[['E', 'F', 'G'], ['B', 'C', 'D'], ['A']]
[['E', 'F', 'G'], ['B', 'A', 'D'], ['C']]
[['E', 'F', 'G'], ['C', 'A', 'D'], ['B']]
Use combinations from itertools:
from itertools import combinations
list(map(list,combinations(list_of_ppl,3)))
[['A', 'B', 'C'],
['A', 'B', 'D'],
['A', 'B', 'E'],
['A', 'B', 'F'],
['A', 'C', 'D'],
['A', 'C', 'E'],
['A', 'C', 'F'],
['A', 'D', 'E'],
['A', 'D', 'F'],
['A', 'E', 'F'],
['B', 'C', 'D'],
['B', 'C', 'E'],
['B', 'C', 'F'],
['B', 'D', 'E'],
['B', 'D', 'F'],
['B', 'E', 'F'],
['C', 'D', 'E'],
['C', 'D', 'F'],
['C', 'E', 'F'],
['D', 'E', 'F']]
Or:
l = list(map(list,combinations(list_of_ppl,3)))
list(map(list,zip(l[::2],l[::-1][::2])))
[[['A', 'B', 'C'], ['D', 'E', 'F']],
[['A', 'B', 'E'], ['C', 'D', 'F']],
[['A', 'C', 'D'], ['B', 'E', 'F']],
[['A', 'C', 'F'], ['B', 'D', 'E']],
[['A', 'D', 'F'], ['B', 'C', 'E']],
[['B', 'C', 'D'], ['A', 'E', 'F']],
[['B', 'C', 'F'], ['A', 'D', 'E']],
[['B', 'D', 'F'], ['A', 'C', 'E']],
[['C', 'D', 'E'], ['A', 'B', 'F']],
[['C', 'E', 'F'], ['A', 'B', 'D']]]
Or:
list(map(list,zip(l,l[::-1])))
[[['A', 'B', 'C'], ['D', 'E', 'F']],
[['A', 'B', 'D'], ['C', 'E', 'F']],
[['A', 'B', 'E'], ['C', 'D', 'F']],
[['A', 'B', 'F'], ['C', 'D', 'E']],
[['A', 'C', 'D'], ['B', 'E', 'F']],
[['A', 'C', 'E'], ['B', 'D', 'F']],
[['A', 'C', 'F'], ['B', 'D', 'E']],
[['A', 'D', 'E'], ['B', 'C', 'F']],
[['A', 'D', 'F'], ['B', 'C', 'E']],
[['A', 'E', 'F'], ['B', 'C', 'D']],
[['B', 'C', 'D'], ['A', 'E', 'F']],
[['B', 'C', 'E'], ['A', 'D', 'F']],
[['B', 'C', 'F'], ['A', 'D', 'E']],
[['B', 'D', 'E'], ['A', 'C', 'F']],
[['B', 'D', 'F'], ['A', 'C', 'E']],
[['B', 'E', 'F'], ['A', 'C', 'D']],
[['C', 'D', 'E'], ['A', 'B', 'F']],
[['C', 'D', 'F'], ['A', 'B', 'E']],
[['C', 'E', 'F'], ['A', 'B', 'D']],
[['D', 'E', 'F'], ['A', 'B', 'C']]]
for v in list(map(list,zip(l,l[::-1]))):
print(v)
[['A', 'B', 'C'], ['D', 'E', 'F']]
[['A', 'B', 'D'], ['C', 'E', 'F']]
[['A', 'B', 'E'], ['C', 'D', 'F']]
[['A', 'B', 'F'], ['C', 'D', 'E']]
[['A', 'C', 'D'], ['B', 'E', 'F']]
[['A', 'C', 'E'], ['B', 'D', 'F']]
[['A', 'C', 'F'], ['B', 'D', 'E']]
[['A', 'D', 'E'], ['B', 'C', 'F']]
[['A', 'D', 'F'], ['B', 'C', 'E']]
[['A', 'E', 'F'], ['B', 'C', 'D']]
[['B', 'C', 'D'], ['A', 'E', 'F']]
[['B', 'C', 'E'], ['A', 'D', 'F']]
[['B', 'C', 'F'], ['A', 'D', 'E']]
[['B', 'D', 'E'], ['A', 'C', 'F']]
[['B', 'D', 'F'], ['A', 'C', 'E']]
[['B', 'E', 'F'], ['A', 'C', 'D']]
[['C', 'D', 'E'], ['A', 'B', 'F']]
[['C', 'D', 'F'], ['A', 'B', 'E']]
[['C', 'E', 'F'], ['A', 'B', 'D']]
[['D', 'E', 'F'], ['A', 'B', 'C']]
the built-in itertools has a helper function for doing it.
itertools.combinations
see doc
itertools.combinations(iterable, r)
Return r length subsequences of elements from the input iterable.
Combinations are emitted in lexicographic sort order. So, if the input >iterable is sorted, the combination tuples will be produced in sorted order.
Elements are treated as unique based on their position, not on their value. So if the input elements are unique, there will be no repeat values in each combination.