-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlifo.py
More file actions
40 lines (34 loc) · 1.03 KB
/
Copy pathlifo.py
File metadata and controls
40 lines (34 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class lifo:
class queue:
def __init__(self):
self.item=[]
def empty(self):
return self.item==[]
def enque(self):
a=int(input('Enter Element : '))
self.item.append(a)
print(self.item)
def deque(self):
if self.empty():
print('Queue Underflow')
else : print('Dequeued : ',self.item.pop(0))
print(self.item)
def prinq(self):
print(self.item)
q=queue()
c=1
while(c==1):
print('1.Insert 2. Remove 3. Print')
op=int(input('Enter Option : '))
if op==1:
q.enque()
elif op==2:
if q.empty():
print('Underflow')
else : q.deque()
elif op==3:
if q.empty():
print('Underflow')
else : q.prinq()
else : print('Invalid')
c=int(input('Continue 1/0 : '))