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 = []](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f3cc419d1ee_56966f3cc4126677.jpg)
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
Get step-by-step solutions from verified subject matter experts
