Solution: Teach Your Code to Remember Lots of Things!
We'll cover the following...
This program stores information about you in a dictionary and then prints each piece of information neatly.
The
medictionary 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
forloop goes through each pair one by one, storing them inkeyandvalue.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