0

I'm stuck on a problem which I need to list the combinations of all possible replacements in a string. For instance, if the string is:

"ABCDXY1234ZEFGH"

And the possible replacements are (XY and Z is unchanged):

character 0 to 3 replaced with "IJKL" character 6 to 9 replaced with "5678" character 11 to 14 replaced with "MNOP"

Then the output would be seven strings:

ABCDXY1234ZMNOP, ABCDXY5678ZEFGH, ABCDXY5678ZMNOP, IJKLXY1234ZEFGH, IJKLXY1234ZMNOP, IJKLXY5678ZEFGH, IJKLXY5678ZMNOP.

How would you make this combination? I tried itertools but haven't figured it out yet.

Thank you, geniuses on the internet.

0 Answers0