I am trying to iterate over two lists (nested and a flat list) together:
eg:
x_list = ['11', '22']
y_list = [[33, 44], [55, 66, 77]]
for x, y in zip(x_list, y_list):
print(x,y)
output:
11 [33, 44]
22 [55, 66, 77]
but I want to output like:
11 33
11 44
22 55
22 66
22 77
You can iterate over items in y in a nested loop:
for x, y in zip(x_list, y_list):
for i in y:
print(x, i)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With