Need help with lab 4.10.1 all permutations of names in python Input: Julia Lucas Mia
Need help with lab 4.10.1 all permutations of names in python
Input:
Julia Lucas Mia
Here I have taken input from the user and then used split() to separate the words and then converted it into a list.
Then, I have the permutations() function from the itertools to get the list of all the possible combinations of the list of words.
The permutations() function returns the list of tuples, where each tuple has different indexing of the words that were passed to the function permutations().
Next, I have iterated over the list of tuples using a for loop.
Inside the loop, I have used another loop to access the values inside each tuple.
In the inner loop, I have printed the values to the console by seprating them using space.
Next, I have used an empty print() statement to get a new line space.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images