
Exercise for reference:
Please complete the script so that it prints out the value of key b .
d = {"a": 1, "b": 2}
Answer:
d = {"a": 1, "b": 2}
print(d["b"])Explanation:
As you see, accessing dictionary values follows the same syntax as accessing list items. The difference is that lists have indexes, while dictionaries have keys that you create by yourself.