-
Book Overview & Buying
-
Table Of Contents
Python Illustrated
By :
In this chapter, we learned how to handle collections of data with lists, tuples, and dictionaries, new kinds of containers for storing multiple values. Let’s go over them once more, so we surely understand them before we move on to the next chapter.
We first looked at lists. Lists are ordered collections that can be changed. You can create and recognize lists using square brackets []. For example, this is how you’d create an empty list:
my_list = []
Usually, lists would have items in them. We learned how to access these items by both positive and negative indices. An important thing to remember is that lists (tuples too, by the way) are 0-indexed, meaning that the first element of a list is at index 0.
After accessing list items in multiple ways, we practiced modifying lists: adding items at the end with the append() method, placing a new item at a specific index with insert(), and removing items with pop() and remove(). Remember the difference...