Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Initialize an empty list to represent the stack
- stack = []
- # Push elements onto the stack
- stack.append(1)
- stack.append(2)
- stack.append(3)
- # Print the current state of the stack
- print("Stack after pushing elements:", stack)
- # Pop elements from the stack
- popped_element = stack.pop()
- print("Popped element:", popped_element)
- # Print the current state of the stack after popping
- print("Stack after popping:", stack)
Advertisement
Add Comment
Please, Sign In to add comment