What I already have so far:
from itertools import permutations
word = str(input())
for subset in permutations(word,len(word)):
print(subset)
What I already have so far:
from itertools import permutations
word = str(input())
for subset in permutations(word,len(word)):
print(subset)
To know the number of combinations, simply save them all in a list and check after your size.
from itertools import permutations
word = str(input())
sequences = list(permutations(word,len(word)))
for subset in sequences:
print(subset)
print("Número de sequências:", len(sequences))
If the list is too large and you do not want to store it all in memory, just create an auxiliary counter:
from itertools import permutations
word = str(input())
sequences = permutations(word,len(word))
total = 0
for subset in sequences:
total += 1
print(subset)
print("Número de sequências:", total)
I think adding this line at the end of the code outside the loop works:
print(len(permutations(word,len(word))))
The previous solution does not work, so I would use the same Woss solution:
from itertools import permutations
word = str(input())
count = 0
for subset in permutations(word,len(word)):
count += 1
print(subset)
print(count)