Quick Print – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  


Shop
siteicon
Solved Problem Solved Problem#PYTHON#6539

Problem Statement - B03C-2015D

Write PUSH (Books) and POP (Books) methods in python to add Books and remove Books considering them to act as Push and Pop operations of Stack.

Solution

def push(Books):
    Stack.append(Books)
    print ‘Element:',Book,'inserted successfully'
def pop():
    if Stack == []:
        print('Stack is empty!')
    else:
        print('Deleted element is',Stack.pop())