CBSE Class 12 Computer Science
Question 52 of 63
Data Structures in Python — Question 26
Back to all questions 26
Question Write AddCustomer(Customer) and DeleteCustomer(Customer) methods in Python to add a new Customer and delete a Customer from a List of CustomerNames, considering them to act as push and pop operations of the Stack data structure.
def AddCustomer(Customer):
Customer_name = input("Enter the customer name: ")
Customer.append(Customer_name)
def DeleteCustomer(Customer):
if Customer == []:
print("Customer list is empty")
else:
print("Deleted Customer name:", Customer.pop())
Customer = []
AddCustomer(Customer)
AddCustomer(Customer)
AddCustomer(Customer)
print("Initial Customer Stack:", Customer)
DeleteCustomer(Customer)
print("Customer Stack after deletion:", Customer)Enter the customer name: Anusha
Enter the customer name: Sandeep
Enter the customer name: Prithvi
Initial Customer Stack: ['Anusha', 'Sandeep', 'Prithvi']
Deleted Customer name: Prithvi
Customer Stack after deletion: ['Anusha', 'Sandeep']