Unit: Unit 4: Strings, Lists, and Tuples • Interactive Practice
Interactive Python programming tutorial and practice in your browser.
# Access elements from the inventory list
inventory = ["laptop", "mouse", "keyboard", "monitor", "headphones"]
# 1. Access the first item (index 0)
first_item = inventory[0]
# 2. Access the third item (index 2)
third_item = inventory[2]
# 3. Access the last item using negative index -1
last_item = inventory[-1]
print("First item:", first_item)
print("Third item:", third_item)
print("Last item:", last_item)