-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstack.py
More file actions
54 lines (46 loc) · 642 Bytes
/
stack.py
File metadata and controls
54 lines (46 loc) · 642 Bytes
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# Stack Data Structure
'''
Stack Operations:-
1. Push()
2. Pop()
3. isEmpty()
'''
stack = []
def push(stack, a):
stack.append(a)
def pop(stack):
if isEmpty():
print("Stack is empty")
else:
stack.pop()
def isEmpty():
if stack:
return False
else:
return True
push(stack,2)
print(stack)
push(stack,3)
print(stack)
push(stack,4)
print(stack)
push(stack,5)
print(stack)
push(stack,6)
pop(stack)
print(stack)
pop(stack)
print(stack)
pop(stack)
print(stack)
pop(stack)
print(stack)
pop(stack)
print(stack)
pop(stack)
print(stack)
pop(stack)
print(stack)
pop(stack)
print(stack)
pop(stack)