Unit: Unit 5: Dictionaries and Sets • Interactive Practice
Interactive Python programming tutorial and practice in your browser.
# Add new keys and update existing values
product = {
"sku": "KB-900",
"name": "Mechanical Keyboard",
"price": 89.99
}
# 1. Update an existing key's value
product["price"] = 79.99
# 2. Add a brand new key-value pair
product["in_stock"] = True
# 3. Batch update multiple fields using .update()
product.update({"rating": 4.8, "warranty_months": 24})
print("Updated product:", product)