Two simple lists
Input
product_pairs([1, 2], ['a', 'b'])
Output
[(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b')]
All combinations of elements from the first and second lists.
Full lesson preview
Create Cartesian products between two iterables to generate coordinate pairs. itertools.product simplifies the task.
Problem statement
Task
Examples
Input
product_pairs([1, 2], ['a', 'b'])
Output
[(1, 'a'), (1, 'b'), (2, 'a'), (2, 'b')]
All combinations of elements from the first and second lists.
Input format
Output format
Constraints
Samples
Input
product_pairs([0, 1], 'ab')
Output
[(0, 'a'), (0, 'b'), (1, 'a'), (1, 'b')]
Combines numbers with characters producing coordinate-like pairs.