+ 1
What will be code if we want to print only those permuted strings starting with 'A' ???
from itertools import product, permutations letters = ("A", "B") print(list(permutations(letters)))
2 Réponses
+ 4
You can try this:
from itertools import product, permutations
letters = ("A", "B","C")
print(list(permutations(letters))) # for information only
print([i for i in list(permutations(letters)) if i[0].startswith('A')])
+ 3
Both of u..Thnx a lot😊