Push Operation on Stack
📖 Scenario: Imagine you have a stack of books. You want to add a new book on top of the stack. This is called the push operation in stacks.
🎯 Goal: You will create a stack using a list, set a new book to add, push it onto the stack, and then print the stack to see the new book on top.
📋 What You'll Learn
Create a list called
stack with these exact books: 'Math', 'Science', 'History'Create a variable called
new_book and set it to 'English'Use the
append() method on stack to push new_book onto the stackPrint the
stack list to show the books after pushing💡 Why This Matters
🌍 Real World
Stacks are used in many places like undo features in apps, browser history, and managing tasks in order.
💼 Career
Understanding stack operations is important for software development, especially in areas like parsing, memory management, and algorithm design.
Progress0 / 4 steps