3. Write a program that depending upon user’s choice, either pushes or pops an element in a stack. The elements are shifted towards right so that top always remains at 0th (zeroth) index.
# Code def push(stack, x): stack.insert(0, x) # this way top is always at the front def pop(stack): return stack.pop(0) # pops from the front because it is the top l = [4, 5, 6, 7] push(l, 8) # l becomes [8, 4, 5, 6, 7] x = pop(l) print(x) # x is 8