Lecture

Removing a Specific Element from a Dictionary

When deleting data from a dictionary, specify the item to remove using itskey.

To remove a specific key-value pair, use the del keyword with the key inside square brackets ([]).

Removing a Value from a Dictionary
order = { "product_id": 2, "product_name": "Computer", "quantity": 3, "price": 1000 } # Remove the "quantity" key and its value del order["quantity"]
Quiz
0 / 1

Use the del keyword to remove a specific key-value pair from a dictionary.

True
False

Lecture

AI Tutor

Design

Upload

Notes

Favorites

Help

Code Editor

Run
Generate

Execution Result