To generate all 8-chars combinations from a list of 70 elements will be extremely costly, 70 8 (576,480,100,000,000) combinations ... Good luck: P
To generate all possible combinations, including repeated characters, use product
:
from itertools import product
caracteres = [0, 1, 2]
permsList = []
genComb = product(caracteres, repeat=2) # aqui e onde tens de especificar o numero de chars que cada combinacao tenha
for subset in genComb:
print(subset) # tuple retornado com uma combinacao por loop
permsList.append(subset)
print(permsList) # [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]
Neither do you need the for loop (unless you need to do some more operation in the loop) simply turn generator returned in a list / set / tuple to store the results, all you need is this:
from itertools import product
caracteres = [0, 1, 2]
permsList = list(product(caracteres, repeat=2))
print(permsList) # [(0, 0), (0, 1), (0, 2), (1, 0), (1, 1), (1, 2), (2, 0), (2, 1), (2, 2)]
You can also remove the tuples and get a list of strings, for this, since we have integers and not strings we have to transform them into string:
from itertools import product
caracteres = [0, 1, 2]
permsList = [''.join(str(i) for i in x) for x in product(caracteres, repeat=2)]
print(permsList) # ['00', '01', '02', '10', '11', '12', '20', '21', '22']
If you have strings instead of integers in tuples, you can only:
permsList = [''.join(x) for x in product(caracteres, repeat=2)]