Examine any combination of values in multiple arrays

It seemed easy to do with ʻitertools.product`. It seems to be useful when solving programming problems or writing tests that comprehensively inspect for problems with all values.

import itertools
numbers = (1, 2, 3)
people = ('Alice', 'Bob')
for person, number in itertools.product(people, numbers):
	print '%s => %d' % (person, number)

The result is as follows:

Alice => 1
Alice => 2
Alice => 3
Bob => 1
Bob => 2
Bob => 3

Recommended Posts

Examine any combination of values in multiple arrays
Sum of multiple numpy arrays (sum)
Bulk replacement of strings in Python arrays
[Python] Takes representative values ​​of multiple images [Numpy]
How to display multiple images of galaxies in tiles
Examine the parameters of RandomForestClassifier in the Kaggle / Titanic tutorial
Settings for easy selection of multiple kernels in Jupyter
Quickly list multiple lines of text in your code
How to retrieve multiple arrays using slice in python.
Display a histogram of image brightness values in python