Lists are a big deal. It really can’t be overemphasized what a big deal they are. Lists are not only used for iterating through data, but they are also a popular data storage and
categorization method used for handling data as a program is running. For anyone who’s programmed in another language, lists are often known as arrays.
Lists may be either very simple or very complex, but they all follow the same rules. Lists may contain different types of data, but be careful when working with it. If you create a list that mixes, say, strings and floats, be sure not to try to call a string method on a list item containing a float.
Remember when the string guides said that strings were just a list of characters. Well, now’s the time to be glad that you paid attention to strings. You can do many of the same things that you did
with strings with lists, and you can do them in the same way. So, some of this is going to feel like a repeat of the string guide, but don’t break focus. There are differences, and there are list
specific methods, so assuming that strings and lists are the exact same this will get you into trouble.
Creating a List
Creating a list is a bit different than the other variables that you’ve learned about so far. You can create a list with absolutely no values in it at all. This is useful for situations where you
don’t exactly know what will be added to the list because the data isn’t in the program yet. There will also be plenty of situations where you won’t be sure how many entries will be in a list, so
again, creating an empty one and adding data later is the right move.