I have the following lists:
sectors = ["A", "B"]
rows = [['1', '2', '3'], ['1', '2', '3', '4']]
seats = [['ab', 'abcd', 'ab'], ['ab', 'abcd', 'ab', 'abcd']]
and I want to create products like A1a, A1b, A2a, A2b, A2c ...
this code
combinations = []
for i in range(len(rows)):
c = list(zip_longest(repeat(sectors[i], len(rows[i])), rows[i], seats[i]))
combinations += c
for c in combinations:
for x in product(*c):
print("".join(x))
prints the desired results as A1a A1b A2a A2b A2c A2d A3a ...
Can this be solved in a better and more readable way, I am practicing itertools and it is a bit confusing for me.
print(", ".join(x))to list be separated with comma and one whitespace.