Find All Possible Combinations
I asked this question earlier but regarding another programming languages. Let's say I have a couple roots, prefixes, and suffixes. roots = ['car insurance', 'auto insurance'] pref
Solution 1:
Use itertools.product()
:
forp, r, sinitertools.product(prefix, roots, suffix):
printp, r, s
Solution 2:
There's no need to import libraries as Python has builtin syntax for this already. Rather than just printing, it returns a data structure like you asked for, and you get to join the strings together to boot:
combinations = [
p + " " + t + " " + s
fortin ts forpin prefix forsin suffix]
Post a Comment for "Find All Possible Combinations"