9/4/26Less than 1 minuteAbout 146 words
Concept: Dictionary
A dictionary is a collection of key-value pairs, where each key is unique and maps to a specific value. Dictionaries are unordered, meaning that the items do not have a defined order, and they are mutable, allowing you to add, remove, or change items after the dictionary has been created.
Keys must be of an immutable data type, such as strings, numbers (float and int), or tuples of those types. The values can be of any data type, including dictionaries, lists, functions[1], or other complex data structures.
Dictionaries are created using curly braces {} and separating the key-value pairs with commas. Each key is separated from its value by a colon :.
config = {
"hostname": "srv01.example.com",
"ip_address": "192.168.1.10",
"services": ["ssh", "http", "ssh"]
}Functions wil be covered in the next chapter. ↩︎