-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstack.py
More file actions
33 lines (26 loc) · 669 Bytes
/
Copy pathstack.py
File metadata and controls
33 lines (26 loc) · 669 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
'''
Author: Davide Pollicino
Date: 05/02/2020
Summary: Implement a stack in Python using a list
'''
# Create an empty List that is going to be used as Stack
stack = []
# Add (push()) value inside our stack
stack.append(1)
stack.append(2)
stack.append(3)
stack.append(4)
stack.append(5)
# Print the content of the stack
print('\nStack: ')
print(stack)
# Pop elements from the stack
print('\nstart of pop operations: ')
print(stack.pop())
print(stack.pop())
print(stack.pop())
print(stack.pop())
print('\nStack after the pop operations: ')
print(stack)
# Get the size of the stack => Number of elements inside the list
print('Size of the stack:', len(stack))