如果我理解正确,您需要列表中六项的所有可能组合。itertools.combinations
应该使这很容易:
>>> import itertools
>>> a_list=['chicken','pizza','burger','beer','vodka','potato','fries','mustache']
>>> a_set=set(itertools.combinations(a_list, 6))
>>> pprint(a_set)
{('burger', 'beer', 'vodka', 'potato', 'fries', 'mustache'),
('chicken', 'beer', 'vodka', 'potato', 'fries', 'mustache'),
('chicken', 'burger', 'beer', 'potato', 'fries', 'mustache'),
('chicken', 'burger', 'beer', 'vodka', 'fries', 'mustache'),
('chicken', 'burger', 'beer', 'vodka', 'potato', 'fries'),
('chicken', 'burger', 'beer', 'vodka', 'potato', 'mustache'),
('chicken', 'burger', 'vodka', 'potato', 'fries', 'mustache'),
('chicken', 'pizza', 'beer', 'potato', 'fries', 'mustache'),
('chicken', 'pizza', 'beer', 'vodka', 'fries', 'mustache'),
('chicken', 'pizza', 'beer', 'vodka', 'potato', 'fries'),
('chicken', 'pizza', 'beer', 'vodka', 'potato', 'mustache'),
('chicken', 'pizza', 'burger', 'beer', 'fries', 'mustache'),
('chicken', 'pizza', 'burger', 'beer', 'potato', 'fries'),
('chicken', 'pizza', 'burger', 'beer', 'potato', 'mustache'),
('chicken', 'pizza', 'burger', 'beer', 'vodka', 'fries'),
('chicken', 'pizza', 'burger', 'beer', 'vodka', 'mustache'),
('chicken', 'pizza', 'burger', 'beer', 'vodka', 'potato'),
('chicken', 'pizza', 'burger', 'potato', 'fries', 'mustache'),
('chicken', 'pizza', 'burger', 'vodka', 'fries', 'mustache'),
('chicken', 'pizza', 'burger', 'vodka', 'potato', 'fries'),
('chicken', 'pizza', 'burger', 'vodka', 'potato', 'mustache'),
('chicken', 'pizza', 'vodka', 'potato', 'fries', 'mustache'),
('pizza', 'beer', 'vodka', 'potato', 'fries', 'mustache'),
('pizza', 'burger', 'beer', 'potato', 'fries', 'mustache'),
('pizza', 'burger', 'beer', 'vodka', 'fries', 'mustache'),
('pizza', 'burger', 'beer', 'vodka', 'potato', 'fries'),
('pizza', 'burger', 'beer', 'vodka', 'potato', 'mustache'),
('pizza', 'burger', 'vodka', 'potato', 'fries', 'mustache')}