-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack.py
40 lines (40 loc) · 848 Bytes
/
stack.py
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 stack:
def __init__(self):
self.stck = []
def push(self, x):
self.stck.append(x)
def pop(self):
if len(self.stck) == 0:
print("No Element to Pop")
else:
self.stck.pop()
def show(self):
print(self.stck)
print("Stack Created")
s = stack()
print("Element 10 Pushed into Stack")
s.push(10)
s.show()
print("Element 20 Pushed into Stack")
s.push(20)
s.show()
print("Element 30 Pushed into Stack")
s.push(30)
s.show()
print("Element 40 Pushed into Stack")
s.push(40)
s.show()
print("Element Poped from Stack")
s.pop()
s.show()
print("Element Poped from Stack")
s.pop()
s.show()
print("Element Poped from Stack")
s.pop()
s.show()
print("Element Poped from Stack")
s.pop()
s.show()
print("Again performing pop from Stack")
s.pop()