I would like to produce all combinations of certain length by using a set of allowed characters with replacement:
I thought itertools.combinations_with_replacement
is what I need. So this is what I did:
from itertools import combinations_with_replacement
allowed = ['0', '1', '8', '6', '9']
comb = list(combinations_with_replacement(allowed,2))
Yet the number of combinations thus produced is 15. But it should be 25 (5^2). What is going on?
EDIT:
I replaced combinations_with_replacement
with permutations
as suggested by @Michael Bianconi but it did not work either - I get a result set of 20, not 25.