Q. 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.

Answer =

def AddCustomer(Customer,item)  :
    CustomerNames.append(item)

def DeleteCustomer( Customer)  :
    CustomerNames.pop()

CustomerNames = [ ] 
while True :
    print()
    print("Enter your choise as per given -")
    print("1 = For insert data Enter insert ")
    print("2 = For delete data enter delete ")
    print("3 = For Exit  enter exit ")
    print()
    user = input("Enter your choise :- ")
    if user == "insert" :
        name = input("Enter the name of member :-")
        AddCustomer(CustomerNames, name)
        
    elif user == "delete" :
        if CustomerNames = [] :
            print("UnderFlow")
        else :
            DeleteCustomer( Customer) 
    else :
        break
    print("Now our CustomerNameseue = ",CustomerNames)

2 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. Write a program to implement a stack for this book details [bookname and booknumber]just implement push and display operation

    ReplyDelete
    Replies
    1. All script are similar only for Display use print statement.

      Delete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post