0% found this document useful (0 votes)
7 views1 page

Queue Implementation in Python

The document outlines a simple implementation of a queue using a list in Python, allowing users to insert, delete, and display elements. Users can choose to insert a number, delete the front element, or display the current queue contents. The program continues to run until the user decides to stop.

Uploaded by

nothinga921
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

Queue Implementation in Python

The document outlines a simple implementation of a queue using a list in Python, allowing users to insert, delete, and display elements. Users can choose to insert a number, delete the front element, or display the current queue contents. The program continues to run until the user decides to stop.

Uploaded by

nothinga921
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#Implementing List as a Queue - using function append() and pop()

a=[]
c='y'
while (c=='y'):
print ("1. INSERT")
print ("2. DELETE ")
print ("3. Display")
choice=int(input("Enter your choice: "))
if (choice==1):
b=int(input("Enter new number: "))
[Link](b)
elif (choice==2):
if (a==[]):
print("Queue Empty")
else:
print ("Deleted element is:",a[0])
[Link](0)
elif (choice==3):
l=len(a)
for i in range(0,l):
print (a[i])
else:
print("wrong input")
c=input("Do you want to continue or not: ")

You might also like