Computer Science, asked by cutiee2k3, 4 months ago

1. A particular stack is being implemented as a list (named Books), where every element
is again a list containing two pieces of information - book_no and title. Write the functions Push(Books) and
Pop(Books) to add a new book and to delete a book considering them as push and pop operations of the
stack data structure. Note: Ask the user input in the Push(Books) function itself.​

Answers

Answered by jai696
4

\large\mathsf\color{pink}{Solution\: using\: python\: 3}

def Push(Books):

no, title = int(input("no: ")), input("title: ")

return Books.append([no, title])

def Pop(Books):

if len(Books) > 0:

item = Books[-1]

print(item)

return Books.remove(item)

Books = []

for _ in range(5):

Push(Books)

for _ in range(5):

Pop(Books)

\large\mathsf\color{lightgreen}useful?\: \color{white}\longrightarrow\: \color{orange}brainliest!

Similar questions