Finding the number of combinations possible, given 4 dictionaries


Given the following dictionaries:

dict_first_attempt = {'Offense': ['Jack','Jill','Tim'], 
dict_second_attempt = {'Offense': ['Jack','McKayla','Heather'],

From this dictionaries, my focus is just the offense, so if I just wanted the list of those, I would do this:

first = dict_first_attempt['Offense']
second = dict_second_attempt['Offense']

For each of those lists, I am trying to create a code that can do the following:

  1. Tell me all the possible combinations of first attempt offense and second attempt offense.
  2. Outputs it in a list, with lists of the combinations.
  3. The first element within the list has to be from the first attempt offense, and the second element has to be from the second attempt offense.

An example of the type of output I want is:

Asked By: PKrange



import itertools
list(itertools.product(first, second))
Answered By: amirhm
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.