Iterating after pairs in string in Python
问题 Here is the combination / permutator generator function that uses any number of lists with values and any length of template strings. The generator creates corresponding lists with combinations / permutations of values matching the template string. The answer was given by a colleague here: https://stackoverflow.com/a/48121777/8820330 from itertools import permutations, combinations, product def groups(sources, template, mode='P'): func = permutations if mode == 'P' else combinations keys =