Generation

generate functionSun, 19 Feb 2023

Write a program to reverse a stack

def reverseStack(stack): if len(stack) == 0: return temp = stack.pop() print(temp) reverseStack(stack) stack.append(temp) s = [1,2,3,4,5] reverseStack(s) print(s)

Questions about programming?Chat with your personal AI assistant