Question: This is the code I used for stack_reverse: reverse = [] while not source.is_empty(): value = source.pop() reverse.insert(0,value) reverse.reverse() while reverse != []: source.push(reverse[0]) reverse.pop(0)

 This is the code I used for stack_reverse: reverse = []

This is the code I used for stack_reverse:

reverse = []

while not source.is_empty():

value = source.pop()

reverse.insert(0,value)

reverse.reverse()

while reverse != []:

source.push(reverse[0])

reverse.pop(0)

return

I just need help with the code when testing from t03. Thanks!

3. Write and test the following function that uses a Stack: def stack_reverse(source): Reverses the contents of a stack. Use: stack_reverse (source) a Stack (Stack) Parameters: source Returns: None Add the function to a PyDev module named functions.py. Test it from t03.py. This function uses a stack, meaning you may manipulate the stack using only the stack interface methods: push, pop, is_empty, and peek. You may not use or refer to the internal Stack elements such as _values

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!