

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 3
click for more info
Not enough gems
Cost: 6 gems
1: Dictionaries
incomplete
2: Duplicate Keys
incomplete
3: Accessing Dictionary Values
incomplete
4: Setting Dictionary Values
incomplete
5: Updating Dictionary Values
incomplete
6: Deleting Dictionary Values
incomplete
7: Counting Practice
incomplete
8: Iterating Over a Dictionary in Python
incomplete
9: Ordered or Unordered?
incomplete
10: Quest Status
incomplete
11: Merge Dictionaries
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
You can delete existing keys using the del keyword.
names_dict = {"jack": "bronson", "jill": "mcarty", "joe": "denver"}
del names_dict["joe"]
print(names_dict)
# Prints: {'jack': 'bronson', 'jill': 'mcarty'}
Notice that if you try to delete a key that doesn't exist, you'll get an error.
names_dict = {"jack": "bronson", "jill": "mcarty", "joe": "denver"}
del names_dict["unknown"]
# ERROR HERE, key doesn't exist