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
![0
19
RI
A learn.zybooks.com/zybook/CYB_135_55317605/chapter/4/section/10
= zyBooks My library > CYB/135: Object-Oriented Security Scripting home > 4.10: LAB: All permutations of names
E zyBooks catalog e Help/FAQ 8 Ricky Ortiz -
Due 07/08/2022, 7.59 PM EDT
4.10 LAB: All permutations of names
Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one
word names, then use a recursive method to create and output all possible orderings of those names, one ordering per line.
When the input is:
Julia Lucas Mia
then the output is (must match the below ordering):
Julia Lucas Mia
Julia Mia Lucas
Lucas Julia Mia
Lucas Mia Julia
Mia Julia Lucas
Mia Lucas Julia
LAB
4.10.1: LAB: All permutations of names
ACTIVITY
OL/O
main.py
Load default template...
[) - səs
if len(namelist) =- 0:
4.
return []
if len namelist) 1.
8.
d.
enter
7.
shih &
B.
alt
ctrl](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2f8ed8ef-22db-479b-97c2-724e226c1280%2F248f21c3-c8b8-40d1-a3c3-5e7487f35f56%2Ftkyv5bc_processed.jpeg&w=3840&q=75)


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









