Skip to the content

Changing lists

Python · Unit 5: Lists

A list can be changed after you create it. To change one item, you give it a new value using its index.

scores = [70, 50, 90]
scores[1] = 80
print(scores)

Prints

[70, 80, 90]

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. Predict the output

    What does this code print?

  2. 2. Complete the code

    Complete it so the second product costs 25.

  3. 3. Predict the output

    What does this code print?

  4. 4. Find the bug

    This program should add "Wed" at the end of the days. Which line has the error?

  5. 5. Predict the output

    What does this code print?

  6. 6. Complete the code

    Complete it so Jake ends up at the front of the line.

  7. 7. Find the bug

    This program should add milk to the list and print it. Which line has the error?

  8. 8. Predict the output

    What does this code print?

  9. 9. Predict the output

    What does this code print?

  10. 10. Put the lines in order

    Put the lines in order to print [1, 4, 9], the squares of 1 to 3.

  11. 11. Multiple choice

    What does this code do to the line?

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 →