Dec-13-2018, 11:05 AM
(This post was last modified: Dec-13-2018, 11:05 AM by jarrod0987.)
What I want to do it to use Product from itertools.
I want the length of the product to be variable.
so for example...
var = 'AB'
If I had product(var, var)
I would get
AA
AB
BA
BB
If product(var, var, var)
AAA
AAB
ABA etc...
what if want to make it so I can just tell product I want var 2x or 3 x or 4x such as:
product(var, var)
product(var, var, var)
product(var, var, var, var)
how can I write a simple function so that I send a number for how many times I want to feed var into the product function then get my object back?
Thanks
UPDATE:
Never mind I figured out I can feed a list of lists into Product with a *.
example:
var = [['A', 'B'], ['A', 'B']]
myObject = product(*var)
I want the length of the product to be variable.
so for example...
var = 'AB'
If I had product(var, var)
I would get
AA
AB
BA
BB
If product(var, var, var)
AAA
AAB
ABA etc...
what if want to make it so I can just tell product I want var 2x or 3 x or 4x such as:
product(var, var)
product(var, var, var)
product(var, var, var, var)
how can I write a simple function so that I send a number for how many times I want to feed var into the product function then get my object back?
Thanks
UPDATE:
Never mind I figured out I can feed a list of lists into Product with a *.
example:
var = [['A', 'B'], ['A', 'B']]
myObject = product(*var)