Answers for "Write functions in Python for Push(List) and for Pops(List) for performing Push and Pop operation with a stack of List containing integers"

7

stack data structure python

#using doubly linked list
from collections import deque
myStack = deque()

myStack.append('a')
myStack.append('b')
myStack.append('c')

myStack
deque(['a', 'b', 'c'])

myStack.pop()
'c'
myStack.pop()
'b'
myStack.pop()
'a'

myStack.pop()

#Traceback (most recent call last):
 #File "<console>", line 1, in <module>
##IndexError: pop from an empty deque
Posted by: Guest on January-05-2020

Code answers related to "Write functions in Python for Push(List) and for Pops(List) for performing Push and Pop operation with a stack of List containing integers"

Python Answers by Framework

Browse Popular Code Answers by Language