You have been provided with a partial Python code that uses a deque to create a simple data structure. This structure operates on the principle of "Last In, First Out" (LIFO). In this particular problem, you are required to fill in the blanks of the given functions to correctly implement the push and pop operations on this data structure. When you push 'Hello' and 'world!' successively and then pop twice, it should first return 'world!' and then 'Hello'."
Stack
Implementing push and pop operations in deque structure
Report a typo
Fill in the gaps with the relevant elements
from collections import
stack = deque()
def push_stack(val):
stack.(val)
def pop_stack():
return stack.()
push_stack("Hello")
push_stack("world!")
print(pop_stack()) # Output: world!
print(pop_stack()) # Output: HelloCreate a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.