Skip to content

Commit c44a9ad

Browse files
Stack implementation in Python
Implemented stack in python
1 parent 2fdd8b8 commit c44a9ad

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Stack in python

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
stack = []
3+
4+
# append() function to push
5+
# element in the stack
6+
stack.append('a')
7+
stack.append('b')
8+
stack.append('c')
9+
10+
print('Initial stack')
11+
print(stack)
12+
13+
# pop() fucntion to pop
14+
# element from stack in
15+
# LIFO order
16+
print('\nElements poped from stack:')
17+
print(stack.pop())
18+
print(stack.pop())
19+
print(stack.pop())
20+
21+
print('\nStack after elements are poped:')
22+
print(stack)
23+

0 commit comments

Comments
 (0)