1

If given a list of strings such as arr = ["abc", "efgh", "ij"], I want to know all the combinations starting from the first word to the last using recursion.

so the output will look like this:

aei
aej
afi
afj
agi
...
chj

all the codes I see are just using the permutation of one string.

I've been thinking that the concept is something like the fundamental counting principle like the one in the picture but I can't really put it into code.

enter image description here

Holyyy
  • 21
  • 4

1 Answers1

0
import itertools
print([''.join(x) for x in itertools.product('abc', 'efgh', 'ij')])
oskros
  • 3,101
  • 2
  • 9
  • 28