KnowledgeBoat Logo
|

Computer Science

Write AddClient(Client) and DeleteClient(Client) methods in Python to add a new client and delete a client from a list client name, considering them to act as insert and delete operations of the Queue data structure.

Python

Python Queue

1 Like

Answer

def AddClient(client):
    client_name = input("Enter client name: ")
    client.append(client_name)

def DeleteClient(client):
    if client == []:
        print("Queue is empty")
    else:
        print("Deleted client:", client.pop(0))

client = []

AddClient(client)
AddClient(client)
AddClient(client)
print("Initial Client Queue:", client)

DeleteClient(client)
print("Client Queue after deletion:", client)

Output

Enter client name: Rahul
Enter client name: Tanvi
Enter client name: Vidya
Initial Client Queue: ['Rahul', 'Tanvi', 'Vidya']
Deleted client: Rahul
Client Queue after deletion: ['Tanvi', 'Vidya']

Answered By

2 Likes


Related Questions