Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> list(itertools.product([0,1,2],[3,4,5]))
- [(0, 3), (0, 4), (0, 5), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5)]
- >>> my_product([0,1,2], [3,4,5])
- [(0, 3), # element 0 from both iterables
- (0, 4), (1, 3), # elements 0,1 and 1,0 (sums to 1)
- (0, 5), (1, 4), (2, 3), # elements 0,2 and 1,1 and 2,0 (sums to 2)
- (1, 5), (2, 4), # elements 1,2 and 2,1 (sums to 3)
- (2, 5)] # elements 2,2 (sums to 4)
Add Comment
Please, Sign In to add comment