Answer:
def permutations(myList: list)-> list:
if len(myList) <= 1:
return [myList]
perm = []
for i in range(len(myList)):
item = myList[i]
seglists = myList[:i] + myList[i+1:]
for num in permutations(seglists):
perm.append([item] + num)
return perm
data = [1,2,3]
result = permutations(data)
print(result)
Explanation:
The program defines a python function that returns the list of permutations. The program checks if the length of the input list is less than or equal to one. The function declaration identifies the input and output as lists.
The for loop iterate through the list and the permutations are saved in an empty list in the next loop statement. At the end of the program, the list of lists is returned.