I am trying to figure out how to print all the combinations there are for multiple sets of letters without repetition.
An example: A,B,C and X,Y,Z
The combinations would be:
AX AY AZ BX BY BZ CX CY CZ
You can use itertools.product to get what you want.
from itertools import product
a = ['A', 'B', 'C']
b = ['X', 'Y', 'Z']
for i in product(a, b):
print ''.join(i)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With