Skip to content

Commit

Permalink
Merge pull request #44 from Razor-5/patch-4
Browse files Browse the repository at this point in the history
Created code to implement stack using list in python
  • Loading branch information
Burnout-Devil committed Oct 18, 2022
2 parents ae8160c + 14b8f51 commit 990886e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions OperationOfStack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Python program to demonstrate stack implementation using list
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 form 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)
# uncommenting print(stack.pop())
#will cause an IndexError as the stack is now empty

0 comments on commit 990886e

Please sign in to comment.