9. Write a python program to establish all the possible permutations of a given list in the following output.
The output is:
list = [7, 8, 9]
Expected Answer: [(7, 8, 9), (7, 9, 8), (8, 7, 9), (8, 9, 7), (9, 7, 8), (9, 8, 7)]
Answer:
import itertools print(list(itertools.permutations([7,8,9])))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)