I cant seem to wrap my head around how unpacking (*) along with itertools.product() is working with the example below.
for x in product(["ghi","abc"]):
print(x)
output:
('ghi',)
('abc',)
And using *
for x in product(*["ghi","abc"]):
print(x)
output:
('g', 'a')
('g', 'b')
('g', 'c')
('h', 'a')
('h', 'b')
('h', 'c')
('i', 'a')
('i', 'b')
('i', 'c')
How was this output generated? I know product() usually generates the combinations given the number of 'repeat'. As for above, repeat is default to 1. How come a ('a','g') wasnt generated?
I guess what did *["ghi","abc"]
actually produce to the product()
function? I mean I see what the outcome is but I just cant seem to get how it worked.