Key Concepts

Review core concepts you need to learn to master this subject

Lists

primes = [2, 3, 5, 7, 11] print(primes) empty_list = []

In Python, lists are ordered collections of items that allow for easy use of a set of data.

List values are placed in between square brackets [ ], separated by commas. It is good practice to put a space between the comma and the next value. The values in a list do not need to be unique (the same value can be repeated).

Empty lists do not contain any values within the square brackets.

Lists
Lesson 1 of 3
  1. 1
    When we start writing more complex programs, we’ll start working with more pieces of data. But data can get messy real fast if we’re not careful. To keep our data tidy, we’ll want to use _data st…
  2. 2
    Lists order items so that they’re in a specific sequence. For example the comic strip, as a list, stores frames in a specific order. Without an order, the story wouldn’t make sense! This idea of…
  3. 3
    After a list is created, we’re able to add things to it. When we add things to the end of an existing list, we say that we’re appending them to the end. Imagine we’re trying out different endi…
  4. 4
    We’re also able to remove items from a list. Similar to adding items, we can modify lists by taking off the last item, or we can use indexing to select a specific item and remove it from the list…
  5. 5
    Great! Now that you know all about lists, let’s write some code. There are many ways to create lists and they can change depending on what language you are programming in. Here’s an example of a …
  6. 6
    Congratulations! Now you’ve learned about another data type known as a list. - A list is an ordered sequence of information - You can access an item in a list by using its index position - Yo…