SOURCE CODE
def addbook(book):
bk = input("enter the book name:")
price = int(input("enter price:"))
[Link]([bk, price])
print(message[1])
def removebook(book):
if book == []:
print(message[3])
else:
item = [Link]()
print(item, message[2])
def displaybooks(book):
if book == []:
print(message[0])
else:
top = len(book) - 1
for i in range(top, -1, -1):
print(book[i])
ook = []
b
message = ['stack empty', 'book added', 'book deleted', 'underflow']
ns = 'y'
a
while ans == 'y':
print("[Link]")
print("[Link]")
print("[Link]")
ch = int(input("enter your choice"))
if ch == 1:
addbook(book)
if ch == 2:
removebook(book)
if ch == 3:
displaybooks(book)
ans = input("do you want to continue?(y/n)")
OUTPUT
.Push
1
[Link]
[Link]
enter your choice 1
enter the book name: Python Basics
enter price: 450
book added
do you want to continue?(y/n) y
.Push
1
[Link]
[Link]
enter your choice 1
enter the book name: Data Science
enter price: 650
book added
do you want to continue?(y/n) y
.Push
1
[Link]
[Link]
enter your choice 3
['Data Science', 650]
['Python Basics', 450]
do you want to continue?(y/n) y
[Link]
[Link]
[Link]
enter your choice 2
['Data Science', 650] book deleted
o you want to continue?(y/n) y
d
[Link]
[Link]
[Link]
enter your choice 3
['Python Basics', 450]
do you want to continue?(y/n) y
[Link]
[Link]
[Link]
nter your choice 2
e
['Python Basics', 450] book deleted
do you want to continue?(y/n) y
[Link]
[Link]
[Link]
enter your choice 2
underflow