Skip to the content

Creating and indexing

Python · Unit 5: Lists

A list keeps several values in order. You write it inside brackets [], with commas between the values.

When you print it, Python shows the text in single quotes: it is the same thing.

fruits = ["fig", "plum", "kiwi"]
print(fruits)

Prints

['fig', 'plum', 'kiwi']

The rest of the explanation is in the lesson, which is part of the full plan.

Exercises in this lesson

You do them in the app, which checks them on the spot and explains why.

  1. 1. Multiple choice

    Which of these lines creates a list with three numbers?

  2. 2. Predict the output

    What does this code print?

  3. 3. Complete the code

    Complete it to print "Ava", the third one in line.

  4. 4. Predict the output

    What does this code print?

  5. 5. Multiple choice

    With this list, which of these gives "b"?

  6. 6. Predict the output

    What does this code print?

  7. 7. Find the bug

    This program should print the last person in line. Which line has the error?

  8. 8. Put the lines in order

    Put the lines in order to print the last price using len().

  9. 9. Predict the output

    If the person types 2, what does it print?

  10. 10. Find the case that fails

    last(items) should return the last item, or None if the list is empty. Which call makes it fail?

Do this lesson

It opens in your browser. This lesson is part of the full plan; the first unit of each course is free.

See all lessons →