Rotate your phone or change to desktop for better experience

Rotate your phone or change to desktop for better experience

10. Implement Stack

 stack = []

# append() function to push

# element in the stack

stack.append('a')

stack.append('b')

stack.append('c')

print('Initial stack')

print(stack)

# pop() function to pop element from stack in LIFO order

print('\nElements popped from stack:')

print(stack.pop())

print(stack.pop())

print(stack.pop())

print('\nStack after elements are popped:')

print(stack)

Post a Comment

0 Comments