from itertools import combinations persons = ['Adam', 'Liam', 'Bruce', 'Kate', 'Demi'] #generate list of all possible pairs print list(combinations(persons,2))
[('Adam', 'Liam'), ('Adam', 'Bruce'), ('Adam', 'Kate'), ('Adam', 'Demi'), ('Liam', 'Bruce'), ('Liam', 'Kate'), ('Liam', 'Demi'), ('Bruce', 'Kate'), ('Bruce', 'Demi'), ('Kate', 'Demi')]
No comments:
Post a Comment