I want to zip two list with different length
for example
A = [1,2,3,4,5,6,7,8,9]
B = ["A","B","C"]
and I expect this
[(1, 'A'), (2, 'B'), (3, 'C'), (4, 'A'), (5, 'B'), (6, 'C'), (7, 'A'), (8, 'B'), (9, 'C')]
But the built-in zip
won't repeat to pair with the list with larger size.
Does there exist any built-in way can achieve this?
Here is my code:
idx = 0
zip_list = []
for value in larger:
zip_list.append((value,smaller[idx]))
idx += 1
if idx == len(smaller):
idx = 0