Python Fundamentals / Collections
Lesson 25 of 38
Dictionaries
A dictionary stores key-value pairs, like a phone book. Look up values by key; keys must be unique.
Key points
- {key: value}
- d[key] to read
- d.get(key, default) avoids errors
ports = {"ssh": 22, "http": 80, "https": 443}
print(ports["ssh"]) # 22Quiz · +10 XP
Which port is stored under "https" in the example?
Log in to save progress and earn XP.