trying to make a function permutations(s) that takes a set of elemnts and returns a collection of all its permutations, where the permutations are of type tuple. Here is my code:
def permutations(s):
str1 = list(s)
if len(str1) <= 1:
print(s)
else:
for i in range(0, len(s)):
str1[0], str1[i] = str1[i], str1[0]
permutations(str1[1:])
str1[0], str1[i] = str1[i], str1[0]
given this input
print(sorted(permutations({1,2,3})))
it should return
[(1, 2, 3), (1, 3, 2), (2, 1, 3), (2, 3, 1), (3, 1, 2), (3, 2, 1)]
but after alot of headache i can only seem to get
[3][2][3][1][1][2]