Python Write a function revers_all (sequence) that takes an arbitrary nested list sequence with arbitrary elements and returns a new list that has the same nested structure, but where all lists both at the top level and at all nested levels are reserved ("backwards") example reverse_all ([1, 2, 3, [4, 5, ['x', 7]], 8]) becomes [8, [[7, 'x'], 5, 4], 3, 2, 1] I sent parameters can not be changed. It is thus a completely new list to be returned. It is allowed to solve the task recursively or itrelatively or with a compilation of these methods. Your function may not make any readings or printouts Use this program to test import copy   sequence = eval(input()) seq_copy = copy.deepcopy(sequence) result = reverse_all(sequence) print (result) if results is sequence:          print("Your function does not create a new list") if sequence != seq_copy:          print("Your function changes in that submission list")

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18PE
icon
Related questions
Question

Python

Write a function revers_all (sequence) that takes an arbitrary nested list sequence with arbitrary elements and returns a new list that has the same nested structure, but where all lists both at the top level and at all nested levels are reserved ("backwards")

example
reverse_all ([1, 2, 3, [4, 5, ['x', 7]], 8]) becomes
[8, [[7, 'x'], 5, 4], 3, 2, 1]

I sent parameters can not be changed. It is thus a completely new list to be returned.
It is allowed to solve the task recursively or itrelatively or with a compilation of these methods. Your function may not make any readings or printouts

Use this program to test

import copy
 
sequence = eval(input())
seq_copy = copy.deepcopy(sequence)
result = reverse_all(sequence)
print (result)
if results is sequence:
         print("Your function does not create a new list")
if sequence != seq_copy:
         print("Your function changes in that submission list")
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
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