def reverse_reversed(items): Create|and return a new list that contains the items in reverse, but so that whenever each item is itself a list, its elements are also reversed. This reversal of sublists must keep going on all the way down, no matter how deep the nesting of these lists, so you ought to use recursion to solve this problem. The base case handles any argument that is not a list. When the items parameter is a list (use the Python function type or the isinstance operator to check this), recursively reverse the elements that this nested list contains. (List comprehensions might come handy in doing this part of the problem.) Note that this function must create and return a new list to represent the result, and should not rearrange or otherwise mutate the contents of the original list. This same principle should apply to all functions that receive a list argument. In your own programs that compute some important list that you pass to some function from the standard library, isn't life easier when you never have to worry of that function silently mutating the contents of your list? Expected result [5, ['yeah', 4, 3, 21, 1] items [1, [2, 3, 4, 'yeah'], 5] [נננ[[2 ,1זזtttt נננ[[[1 ,2וזזזtt [42, [99, [17, [33, ['bool']]]]][[[[['bool'], 33], 17], 991, 42]

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter18: Stacks And Queues
Section: Chapter Questions
Problem 16PE: The implementation of a queue in an array, as given in this chapter, uses the variable count to...
icon
Related questions
Question

Please help solve the python problem, thank you

Reversing the deserver
def reverse_reversed (items):
Create and return a new list that contains the iteme in reverse, but so that whenever each item is
itself a list, its elements are also reversed. This reversal of sublists must keep going on all the way
down, no matter how deep the nesting of these lists, so you ought to use recursion to solve this
problem. The base case handles any argument that is not a list. When the itema parameter is a list
(use the Python function type or the isinstance operator to check this), recursively reverse the
elements that this nested list contains. (List comprehensions might come handy in doing this part of
the problem.)
Note that this function must create and return a new list to represent the result, and should not
rearrange or otherwise mutate the contents of the original list. This same principle should apply to
all functions that receive a list argument. In your own programs that compute some important list
that you pass to some function from the standard library, isn't life easier when you never have to
worry of that function silently mutating the contents of your list?
Expected result
items
[1, [2, 3, 4, 'yeah'], 5]
[5, ['yeah', 4, 3, 21, 1]
[[[[[[1, 2111]]]
[[[[[[2, 1]]11]]
[42, [99, [17, [33, ['bool']]]]] [[[[['boo!'], 33], 17], 991,
42]
Transcribed Image Text:Reversing the deserver def reverse_reversed (items): Create and return a new list that contains the iteme in reverse, but so that whenever each item is itself a list, its elements are also reversed. This reversal of sublists must keep going on all the way down, no matter how deep the nesting of these lists, so you ought to use recursion to solve this problem. The base case handles any argument that is not a list. When the itema parameter is a list (use the Python function type or the isinstance operator to check this), recursively reverse the elements that this nested list contains. (List comprehensions might come handy in doing this part of the problem.) Note that this function must create and return a new list to represent the result, and should not rearrange or otherwise mutate the contents of the original list. This same principle should apply to all functions that receive a list argument. In your own programs that compute some important list that you pass to some function from the standard library, isn't life easier when you never have to worry of that function silently mutating the contents of your list? Expected result items [1, [2, 3, 4, 'yeah'], 5] [5, ['yeah', 4, 3, 21, 1] [[[[[[1, 2111]]] [[[[[[2, 1]]11]] [42, [99, [17, [33, ['bool']]]]] [[[[['boo!'], 33], 17], 991, 42]
Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Top down approach design
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning