I am trying to create a list with tuples as elements. Each tuple has 4 integers. The 2 first integers are a result of zipping 2 ranges
, while the other 2 from 2 different ones.
I am using this code to create the tuples and the final list, which is derived from the cartesian product, as seen here: Get the cartesian product of a series of lists?
import itertools
first_range = list(zip((10**exp for exp in range(0,7)),(10**exp for exp in range(1,8))))
second_range = list(zip((5*10**exp if exp != 1 else 10**2 for exp in range(1,8)),(5*10**exp for exp in range(2,9))))
final_list = list(itertools.product(first_range,second_range))
The issue with this code is that the final results looks like this:
[((1, 10), (100, 500)), ((1, 10), (500, 5000)), ((1, 10), (5000, 50000)), ((1, 10), (50000, 500000)), ((1, 10), (500000, 5000000)), ((1, 10), (5000000, 50000000)), ...
Where each list element is a tuple containing 2 other tuples, while what I want is this:
[(1, 10, 100, 500), (1, 10, 500, 5000), (1, 10, 5000, 50000), (1, 10, 50000, 500000), (1, 10, 500000, 5000000), (1, 10, 5000000, 50000000), ...
i.e. each list element is a tuple containing 4 integers.
Any ideas would be appreciated. Must be working on python3. EDIT: Updated the non-working parts of the code thanks to ShadowRanger's comments