Common Collection Methods and Best Practices
Over the last several articles, we've explored Python's powerful built-in collection types: lists, tuples, dictionaries, and sets, as well as the specialized containers in the collections module. This article serves as a capstone, summarizing the best practices and helping you decide which collection to use in different scenarios.
Dictionaries (Part 1): Key-value pairs, creating dictionaries, accessing values
After exploring the ordered worlds of lists and **tuples**, we now dive into one of Python's most powerful and flexible data structures: the dictionary. Unlike lists and tuples which are indexed by a range of numbers, dictionaries are indexed by keys, which can be any immutable type.
Dictionaries (Part 2): Dictionary methods and dictionary comprehensions
In the previous article, we learned how to create dictionaries and access their values. Now, we'll explore how to modify, manage, and iterate over them using dictionary methods. We'll also introduce a powerful, Pythonic feature for creating dictionaries: dictionary comprehensions.