List can be seen as a collection: they can hold many variables. An empty list would simply be
In Python you define a list using brackets.

A list can have any number of elements. They are similar to arrays in other programming languages.

Related course: Complete Python Bootcamp: Go from zero to hero in Python

Lists example

Lists can hold both numbers and text. Regardless of contents, they are accessed in the same fashion.

To access a list add the id between the brackets, such as list[0], list[1] and so on.
Type the code below and run it:

This should output:



1. Make a program that displays the states in the U.S.

2. Display all states starting with the letter M