I have the following 2D array:
String[M][] String[0] \"1\",\"2\",\"3\" String[1] \"A\", \"B\" . . . String[M-1] \"!\"
A
In Python one uses itertools.product and argument unpacking (apply)
>>> import itertools >>> S=[['1','2','3'],['A','B'],['!']] >>> ["".join(x) for x in itertools.product(*S)] ['1A!', '1B!', '2A!', '2B!', '3A!', '3B!']