Unit: Unit 4: Strings, Lists, and Tuples • Interactive Practice
Interactive Python programming tutorial and practice in your browser.
# Pop elements from specific index positions in the list
inventory = ["laptop", "wireless mouse", "mechanical keyboard", "monitor"]
# 1. Pop the last item (default index -1)
last_item = inventory.pop()
# 2. Pop the item at index 1 ("wireless mouse")
removed_item = inventory.pop(1)
print("Popped last item:", last_item)
print("Popped index 1 item:", removed_item)
print("Remaining inventory:", inventory)