forked from VivekDubey9/Competitive-Programming-Algos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStack
More file actions
38 lines (24 loc) · 608 Bytes
/
Stack
File metadata and controls
38 lines (24 loc) · 608 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
def Create_Stack():
stack = []
return stack
def isEmpty(stack):
if(len(stack) == 0):
print("Stack is empty")
else:
print("Stack is not empty")
def size(stack):
return len(stack)
def push(stack, n_Element):
stack.append(n_Element)
print(n_Element, "is added into the stack.")
def pop(stack):
print(stack.pop(), "is deleted from the stack.")
def topElement(stack):
return stack[len(stack) - 1]
My_Stack = Create_Stack()
push(My_Stack, 10)
push(My_Stack, 20)
push(My_Stack, 30)
push(My_Stack, 40)
pop(My_Stack)
isEmpty(My_Stack)