a=[] for i in range(10): n=int(input('enter any no')) a.append(n) stack=[] def Push(a): for i in a: if i%3==0: stack.append(i) def Pop(stack): stack.pop() def display(): for i in range(len(stack)-1,-1,-1): print(stack[i]) while True: print('1.Push ') print('2.POP') print('3.Display') print('4 Exit') ch=int(input('enter choice')) if ch==1: Push(a) elif ch==2: Pop(stack) elif ch==3: display() elif ch==4: break ''' OUTPUT enter any no34 enter any no24 enter any no15 enter any no67 enter any no69 enter any no46 enter any no58 enter any no69 enter any no53 enter any no90 1.Push 2.POP 3.Display 4 Exit enter choice1 1.Push 2.POP 3.Display 4 Exit enter choice3 90 69 69 15 24 1.Push 2.POP 3.Display 4 Exit enter choice2 1.Push 2.POP 3.Display 4 Exit enter choice3 69 69 15 24 1.Push 2.POP 3.Display 4 Exit enter choice4 '''