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