Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

student submitted image, transcription available 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... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

Students also viewed these Programming questions

Question

In Exercises find dy/dx by implicit differentiation. xy - y = x

Answered: 1 week ago

Question

Describe how concepts and prototypes influence our thinking.

Answered: 1 week ago