Question: Implement a function that reverses a list of elemnts by pushing them onto a stack in one order, and writing them back to the list
Implement a function that reverses a list of elemnts by pushing them onto a stack in one order, and writing them back to the list in reversed order.
#A simple implementation of stack
class Stack:
definitself:
self.items
def isemptyself:
return self.items
def pushself item:
self. items append item
def popself:
return self.items.pop
def reversesequence:
#TODO: implement this function that reverses a list with a stack
list range
reverseL
printL
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
