Dictionaries
Explore the concepts and uses of Python dictionaries, including how to access, add, update, and delete key-value pairs. Understand dictionary properties such as key uniqueness and immutability to effectively manage data mappings.
We'll cover the following...
We'll cover the following...
Definition
A dictionary (of type dict) provides a fast way of looking something up. Dictionaries are often used when you want to create a mapping from keys to values without having to maintain their order. Additionally, if you want to access items instantly without having to traverse through the whole collection, dictionaries are the way to go.
A dictionary consists of zero or more key:value pairs enclosed in braces, { }. For example, you might define a “phone book” dictionary as follows:
phones = {"Alice":5551212, "Jill":5556789, ...