Search⌘ K
AI Features

Solution: Teach Your Code to Remember Lots of Things!

Understand how to use Python dictionaries to store multiple pieces of information with labeled key value pairs. Learn to loop through dictionary items and display them clearly, building foundational skills for reusable and powerful data management in your programs.

We'll cover the following...

This program stores information about you in a dictionary and then prints each piece of information neatly.

  • The me dictionary holds data in key–value pairs.

    • A key is like a label (e.g., "name").

    • A value is the information that label points to (e.g., "Your Name").

  • me.items() returns all key–value pairs from the dictionary.

  • The for loop goes through each pair one by one, storing them in key and value.

  • The print() statement displays them in a readable format.

Python
me = {
"name": "Your Name",
"hobby": "Something fun",
"language": "Python"
}
for key, value in me.items():
print(key, ": ", value) # Or use key.title() to make it look nicer