Queue using List in DSA Python
by DataFlair Team
Program 1
#Queue implementation using List
queue=[] # empy list
def qinsert():
n=int(input("Enter an element for insert"))
queue.append(n)
def qdelete():
if(len(queue)==0):
print("Queue is empty")
else:
print("Deleted element is: ",queue[0])
del queue[0]
def qdisplay():
if(len(queue)==0):
print("Queue is empty")
else:
print("Elements of Queue")
for element in queue:
print(element)
while(1):
print("---------------------Queue Menu---------------------")
print(" 1.Insert \n 2.Delete \n 3.Display \n 4.Exit")
print("--------------------------------------------------------")
choice=int(input("Enter your choice"))
if(choice==1):
qinsert()
elif(choice==2):
qdelete()
elif(choice==3):
qdisplay()
elif(choice==4):
break
else:
print("Invalid choice")
Tags: dsa pythondsa python program on queue using listdsa using pythondsa using python practicaldsa using python programqueue using listqueue using list in dsa python
DataFlair Team
DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.