Download CD Content
Tuples are a great way to work with sequences of any type, but their immutability can be limiting. Fortunately, another sequence type, called lists, do everything that tuples can, plus more. That's because lists are mutable. Elements can be added or removed from a list. You can even sort or reverse an entire list. You'll also be introduced to another type, dictionaries. Whereas lists work with sequences of information, dictionaries work with pairs of data. Dictionaries, like their real-life counterparts, let you look up one value with another. Specifically in this chapter, you'll learn to do the following:
Create, index, and slice a list
Add and delete elements from a list
Use list methods to append, sort, and reverse a list
Use nested sequences to represent even more complex information
Use dictionaries to work with pairs of data
Add and delete dictionary items