Question
Write a Python program that repeatedly asks the user to enter a list of numbers or strings. The items do not need to be all
Write a Python program that repeatedly asks the user to enter a list of numbers or strings. The items do not need to be all the same type. If the user does not enter a list of a length that is not a multiple of 3, then the program asks the user to enter a different list.
Your program slices the list into 3 equal parts (each of which will be a list). Your program then reverses the contents of each of these parts. Finally, your program displays a list composed of those 3 reversed parts. Your program repeats until the user enters an empty list.
Use a fruitful function to perform the splitting and reversing. Your main driver code should handle the input/output and looping.
Run your program several times using different inputs – sufficient to demonstrate that your program meets all the assignment requirements.
Sample output below:
List Slicing Enter a list of space-separated numbers or strings. The length of the list must be a multiple of 3. List: 1 2 3 3] Original list: [1, 2, 3 Processed list: [['1'], ['2'], ['3]] 72), (3) List: 1 2 3 4 List length must be a multiple of 3 List: a b c d e f 1.1 2.2 3.3 Original list: [a, b, c, d, e, f, 1.1, 2.2, 3.3] Processed list: [['c', 'b', 'a'], ['f', 'e', 'd'], ['3.3, 2.2, 1.1']] List: this is a test of the E. B. S. Original list: [this, is, a, test, of, the, E., B., S.] Processed list: [['a', 'is', 'this'], ['the', 'of', 'test'], ['s.', 'B.', 'E.']] List: Done!
Step by Step Solution
3.38 Rating (157 Votes )
There are 3 Steps involved in it
Step: 1
solution A fruitful function that splits and reverses a list def splitandreverselst Get the length of the list n lenlst Check if the length is a multi...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started