

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 2
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
If you try to set the value of a key that already exists, you'll end up just updating the value of that key.
planets = {
"Pluto": True,
}
planets["Pluto"] = False
print(planets["Pluto"])
# Prints False
Use the example below to answer the question:
full_names = ["jack bronson", "james mcarty", "jack denver"]
names_dict = {}
for full_name in full_names:
# .split() returns a list of strings
# where each string is a single word from the original
names = full_name.split()
first_name = names[0]
last_name = names[1]
names_dict[first_name] = last_name
print(names_dict)
# {
# 'jack': 'denver',
# 'james': 'mcarty'
# }
In this example, denver overwrote bronson as the value for the key jack.