Menu
Coddy logo textTech

Accessing Items

Lesson 4 of 14 in Coddy's Dictionary in Python course.

To access the values in a dictionary refer to its key name, inside square brackets,

my_dict = {"name": "Alice", "age": 30, "city": "New York"}
print(my_dict["name"])  # Output: "Alice"
print(my_dict["age"])   # Output: 30
challenge icon

Challenge

Easy

You are given a dictionary, your task is to access all the items in the dictionary and print its value, keep the dictionary values order!

Try it yourself

# The book dictionary
book = {
    "title": "Python for Beginners",
    "author": "Alice Smith",
    "year": 2022,
    "pages": 200,
    "genre": "Programming",
    "publisher": "Tech Books Inc."
}

# Write code here

All lessons in Dictionary in Python