(ii) Pop_element(): It pops the objects from the stack and displays them. Also, the function should display “Stack Empty” when there are no elements in the stack.
For example: If the nested list contains the following data:
BList=[["The Alchemist", "Paulo Coelho", 250],
["Animal Farm", "George Orwell", 150],
["The Da Vinci Code", "Dan Brown", 350],
["Harry Potter", "J.K. Rowling", 400],
["The Kite Runner", "Khaled Hosseini", 270],
["The Catcher in the Rye", "J.D. Salinger", 200]]
The stack should contain:
['The Alchemist', 'Paulo Coelho'],
['Animal Farm', 'George Orwell'],
['The Catcher in the Rye', 'J.D. Salinger']
The output should be:
['The Catcher in the Rye', 'J.D. Salinger']
['Animal Farm', 'George Orwell']
['The Alchemist', 'Paulo Coelho']
Stack Empty
Answer:
Answer by student
Detailed answer by teachoo
The rest of the post is locked. Join Teachoo Black to see the full post.