Intro to Lists in Python

There are data types in Python that are composed of other data types. The prime example is a list. A list is a collection of objects.

We haven’t really talked about objects before, but in Python anything you can store is an object:

  • All the types we have introduced count as objects:
    • integers
    • strings
    • floats
  • A list itself is also an object.

Those objects can be given names.  Technically, that is what variable assignment really is in Python: giving a name to an object.

To make a list, put objects between square brackets [] , separated by commas: 

  Terminal - Python
>>> myList = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]

The following video introduces lists in Python and visually shows the anatomy (components) of a list.

You have completed 0% of the lesson
0%