My code is pretty simple. My task is to get every permutation of given string. Compute number of permutations - that's clear - factorial.
Code
s = "aba"
perm = list("".join(string) for string in permutations(s))# all permutations
numberOfPerm = len(perm) #number of permutations
unique = len(list(set(perm))) #number of unique permutations
list.sort(perm) # ascii sorting
format_list = [numberOfPerm, unique]
print("total: {} (unique: {}) ".format(*format_list))
print(perm)
Output of this is
total: 6 (unique: 3)
['aab', 'aab', 'aba', 'aba', 'baa', 'baa']
The thing is i need it to be like this
total: 6 (unique: 3) aab, aab, aba, aba, baa, baa
I bumped on various solutions e.g. ''.join(finalArray)
, but none of them work either in my pycharm or in VPL (virtual programming lab) - traceback errors appear. Thanks for eventual help.