Unit: Unit 4: Strings, Lists, and Tuples • Interactive Practice
Interactive Python programming tutorial and practice in your browser.
# Mutate list elements in-place using item assignment
inventory = ["laptop", "mouse", "keyboard"]
# 1. Upgrade "mouse" (index 1) to "wireless mouse"
inventory[1] = "wireless mouse"
# 2. Update the last item (index -1) to "mechanical keyboard"
inventory[-1] = "mechanical keyboard"
print("Updated inventory:", inventory)