To search an element in the stack, we use the search() method. It returns the position of the element from the top of the stack. For example,
Output