Lists

Variables are the memory of Python. Large numbers of variables can be created, and as long as you know what belongs where, you can hold a great amount of data. This can become problematic when we have large sets of related data though, like a collection of student names enrolled in a class. The list data structure aggregates this information into a single place, so rather than forcing you to define name1, name2, name3, and so on, you can declare a list variable and add each name into that structure one-by-one. Think about a class list, or even a phone book. A list is a data structure, like a bucket, that lets you add and remove elements to it as you see fit. This chapter will explain how these collections are created and accessed, and will explain a number of situations where you might.