Lists

Python lists let you store multiple values in a single variable.

They look like this:

Notice that you can have different types of things in a python list. Python lists can also change in size after you've made them by adding or removing list items.

If you're learning C++, python lists have a lot in common with C++ arrays. However, C++ arrays can only hold one kind of thing, and can't grow and shrink after being created like a python list can.

Here's some sample code that shows you how to print individual list items, print an entire list, add a value to a list, and change a value in a list:

For loops are often used to iterate through lists. Here's an example of a for loop that doubles each list value:

Python has an easy to use sorting function. Here's an example of how to add user inputs to a list, and then sort the list: