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.
list = 
Related course: Complete Python Bootcamp: Go from zero to hero in Python
ExampleLists 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, list and so on. Type the code below and run it:
This should output:
Make a program that displays the states in the U.S.
states = [ 'Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','West Virginia','Wisconsin','Wyoming' ]
Display all states starting with the letter M