Check sibling questions
Computer Science - Class 12
Solutions to CBSE Sample Paper - Computer Science Class 12

A list contains following record of a customer:

[Customer_name, Phone_number, City]

Write the following user defined functions to perform given operations

on the stack named ‘status’:

(i) Push_element() - To Push an object containing name and

Phone number of customers who live in Goa to the stack

(ii) Pop_element() - To Pop the objects from the stack and

display them. Also, display “Stack Empty” when there are no

elements in the stack.

For example:

If the lists of customer details are:


[“Gurdas”, “99999999999”,”Goa”]

[“Julee”, “8888888888”,”Mumbai”]


[“Ashmit”, “1010101010”,”Goa”]


The stack should contain




The output should be:



Stack Empty



status=[ ]


def Push_element (c):

    if c[2]== "Goa" :

        obj=[c[ 0 ],c[ 1 ]]



def Pop_element ():

    while len(status)!= 0 :



    print( "Stack empty" )


Learn in your speed, with individual attention - Teachoo Maths 1-on-1 Class

Ask a doubt
Davneet Singh's photo - Co-founder, Teachoo

Made by

Davneet Singh

Davneet Singh has done his B.Tech from Indian Institute of Technology, Kanpur. He has been teaching from the past 13 years. He provides courses for Maths, Science, Social Science, Physics, Chemistry, Computer Science at Teachoo.