I need to get only the permutations that have letters and numbers (The permutation can not be. \"A, B, C, D\" I need it like this: \"A, B, C, 1\")
In short, the perm
You can generate the proper combinations by combining non-empty combinations from the two sequences.
import itertools
def combinations(a, b, n):
for i in xrange(1, n):
for ca in itertools.combinations(a, i):
for cb in itertools.combinations(b, n-i):
yield ca + cb
for r in combinations(list('abcd'), [1, 2, 3, 4], 4):
print r
The number of combinations you get is choose(A+B, n) - choose(A, n) - choose(B, n), where A is the number of elements in a, B the number of elements in b, and "choose" is the binomial coefficient.