Testing Yourself With a Challenge
In this special lesson, I have a challenge for you so you can test your knowledge that you gained during this video course. Here is the challenge. Create an empty dictionary named
Then enter the following data into the dictionary, one item at a time. The data is
"Sisko". All of these are strings, so don’t forget the quotation marks at the beginning and end of them.
Once you’ve added data, write two
if statements to check if
"Discovery" exist as keys in the dictionary.
Set their values to
"unknown" if the key does not exist. Again,
"unknown" is a string here, so don’t forget the quotation marks.
Next, I want you to write a
for loop to display the ship and captain names contained in the dictionary. So for example, you could print a string,
"The Enterprise is captained by Picard". And finally, delete the key
"Discovery" from the dictionary.
01:13 If you’re unsure about how to solve some steps of this challenge, you can revisit some lessons of this video course. I would recommend try solving it first on your own, but if you don’t know how to solve it after trying things, just ask in the comments below, and the community will help you out.
01:32 Once you solve the challenge, hop to the next lesson, where I will summarize the video course for you and give you some resources to learn more about dictionaries.
Become a Member to join the conversation.