Source:
import itertools

def list_combinations(data, num):
    return list(itertools.combinations([i for i in data], num))
Sample Usage:
print list_combinations(['a', 'b', 'c'], 2)
# outputs
# [('a', 'b'), ('a', 'c'), ('b', 'c')]

Get all possible combinations given a data(list of names/numbers) and num(number of people in combination groups.

Pythoneer 6 years ago