PROBLEM:-
CODE IN PYTHON..
8.8 LAB: All permutations of names
Write a program that lists all ways people can line upfor a photo (all permutations of a list of strings). The programwill read a list of one-word names, then use a recursive functionto create and output all possible orderings of those namesseparated by a comma, one ordering per line.
When the input is:
then the output is (must match the belowordering):
THIS IS THE PROMPT I HAVE
def print_all_permutations(permList, nameList):# TODO: Implement method to create and output all permutations ofthe list of names.
if __name__ == "__main__":nameList = input().split(' ')permList = []print_all_permutations(permList, nameList)
.
ANSWER:-
BUT THIS MY OUTPUT
['Julia', 'Lucas', 'Mia']
['Julia', 'Mia', 'Lucas']
['Lucas', 'Julia', 'Mia']
['Lucas', 'Mia', 'Julia']
['Mia', 'Julia', 'Lucas']
['Mia', 'Lucas', 'Julia']
I DON'T WANT IT TO OUTPUT AS A LIST WITH COMMAS BUTINDIVIDUALLY AS A THREE.
PROBLEM:- CODE IN PYTHON.. 8.8 LAB: All permutations of names Write a program that lists all ways people can line up for
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am