Skip to content Skip to sidebar Skip to footer

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

Solution 1:

Define your templates like this:

sources = {
    'a1': [0, 1, 2],
    'a2': [3, 4, 5],
    'a3': [6, 7, 8],
}
templates = [['a1', 'a2', 'a3']]

And then it will work out of the box. The reason this works is that strings in python are in fact just lists of characters, so instead of defining 'abc' you could define ['a', 'b', 'c'] and this behaves the same in most situations.

Post a Comment for "Iterating After Pairs In String In Python"