lundi 29 juin 2015

Combinations between two tuples in Python


I have two tuples:

t1 = ('A', 'B')
t2 = ('C', 'D')

I wonder how to create combinations between tuples, so the result should be:

AC, AD, BC, BD

EDIT

Using

list(itertools.combinations('abcd',2))

I could generate list of combinations for a given string. If I insert tuple instead of string the following error occurs:

TypeError: sequence item 0: expected string, tuple found

Any suggestion how to proceed?


Aucun commentaire:

Enregistrer un commentaire