Skip to content

Commit a4b5df2

Browse files
author
sandeeprawat28
committed
hacktoberfest
1 parent 85030b0 commit a4b5df2

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

DSA/Queue_using_list.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Implement Queue using List(Functions)
2+
q=[]
3+
def Enqueue():
4+
if len(q)==size: # check wether the stack is full or not
5+
print("Queue is Full!!!!")
6+
else:
7+
element=input("Enter the element:")
8+
q.append(element)
9+
print(element,"is added to the Queue!")
10+
def dequeue():
11+
if not q:# or if len(stack)==0
12+
print("Queue is Empty!!!")
13+
else:
14+
e=q.pop(0)
15+
print("element removed!!:",e)
16+
def display():
17+
print(q)
18+
size=int(input("Enter the size of Queue:"))
19+
while True:
20+
print("Select the Operation:1.Add 2.Delete 3. Display 4. Quit")
21+
choice=int(input())
22+
if choice==1:
23+
Enqueue()
24+
elif choice==2:
25+
dequeue()
26+
elif choice==3:
27+
display()
28+
elif choice==4:
29+
break
30+
else:
31+
print("Invalid Option!!!")

0 commit comments

Comments
 (0)