Advertisements
Advertisements
Question
A list contains the following records of customers.
[Customer_name, Room Type]
Write the following user-defined functions to perform given operations on the stack named 'Hotel':
Push_Cust()- Push customers names of those customers who are staying in the 'Delux' Room Type.Pop_Cust()- Pop the names of customers from the stack and display them. Also, display "Underflow" when there are no customers in the stack.
For example:
If the lists with customer details are as follows:
["Siddarth", "Delux"]
["Rahul", "Standard"]
["Jerry", "Delux"]
The stack should contain
Jerry
Siddharth
The output should be:
Jerry
Siddharth
UnderflowCode Writing
Advertisements
Solution
stack=[]
def Push_Cust(Lst):
if Lst[1]=="Delux":
stack.append(Lst[0])
def Pop_Cust():
if len(stack)==0:
print("Underflow")
else:
stack.pop() shaalaa.com
Is there an error in this question or solution?
