Thanks to another post of mine, I found out about itertools.product(). What I was wondering how to do is to code it so that I can use as many arrays as parameters as possible, with the number of arrays being defined by user input. for example, If the user inputted 2 arrays, it would find the combinations of those 2 arrays, and if they entered 10 arrays it would find the combinations of the 10 arrays.

I tried this:

array=[['a','b'],['b','c'],['c','a']]
z=itertools.product(x for x in array)

but that didnt work. any suggestions or help? thanks in advance

You can use itertools.product(*array) , also if your want your result in a list, you write list(itertools.product(*array)) .

Using your example list
array=[['a','b'],['b','c'],['c','a']]
what do you expect the result to look like?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.