The first of the containers we will study

Containers hold stuff

Lists are a specific kind of container

  • Ordered
  • Heterogeneous
  • Grow to what you need


  • Index positions give elements addresses
  • They start at zero.
    • It kind of makes sense. ¬†Eventually.
  • You can ask for elements by their address


  • You can put whatever you want in
  • No, seriously.
  • Anything.
  • Even more lists.


  • Lists will grow as you add things to them
  • They can also be empty

Python is very different

Most languages are very strict about collections and arrays.  Python is incredibly lenient.

How do I list?

mylist = []

Lists are contained in []

You add things to lists via append:


Spend some time with the docs

Future you will thank you

List comprehensions

You will see them around.

You will be confused.

Eventually you will use them.

But don't worry about that until later.

>>> name = "Elizabeth"
>>> [letter.upper() for letter in name]
['E', 'L', 'I', 'Z', 'A', 'B', 'E', 'T', 'H']

This is a completely sane reaction.

Demo time!


By Elizabeth W.


  • 1,174