< eelmine | Table of Contents | next > |
8.1 WHAT IS A LIST?
You can think of a list as something that stores a collection of different items where these items can be changed, removed, accessed, or new items added. In more formal terms, a list is a mutable data type, meaning it can be changed. It is also ordered, meaning that Python will keep track of the order in which the items were entered into the list. It can store all different data types, and the elements in the list can be of mixed type, too. Lists comprise values that are between square brackets []
.
Here’s a very simple example of creating a list and printing its contents to the console. This is a simple list of strings that contains the titles of someone’s favorite songs.
< eelmine | Table of Contents | next > |