Question: It is Python. Thanks Making Code Modular 1 point Consider a program which takes a string containing several words, breaks it into pieces, and reverses

 It is Python. Thanks Making Code Modular 1 point Consider a

It is Python. Thanks

Making Code Modular 1 point Consider a program which takes a string containing several words, breaks it into pieces, and reverses the order of the words as a new string. For instance, the string 'It was the best of times' becomes 'times of best the was it'. The following program implements this logic for a particular string. It uses some programming tools you haven't seen yet, but don't worry: you actually need to change very little to convert this from a standalone program to a reusable function. my_string = 'It was the age of wisdom' words = my_string.split('') new_string = ''.join( words[ ::-1 ] ) Compose a function reverse which accepts an arbitrary string my_string and returns the string with its word order flipped as specified. Make sure to return rather than print the result. As an example, reverse( 'It was the epoch of belief' ) should return 'belief of epoch the was It'. Starter code (click to view) def reverse( my_string)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!