

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 don't need to create a dictionary with values already inside. It is common to create a blank dictionary then populate it later using dynamic values. The syntax is the same as getting data out of a key, just use the assignment operator (=) to give that key a value.
planets = {}
planets["Earth"] = True
planets["Pluto"] = False
print(planets["Pluto"])
# Prints False
Use the example below to answer the question:
full_names = ["jack bronson", "jill mcarty", "john 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
name_parts = full_name.split()
# here we update the dictionary
names_dict[name_parts[0]] = name_parts[1]
print(names_dict)
# Prints: {'jack': 'bronson', 'jill': 'mcarty', 'john': 'denver'}