List operations

Lists can be changed with several methods. What are these methods?

To add items to a list, you can use the append() method. Call the method on the list, the parameter contains the item to add. Calling append(3) would add 3 to the list. To remove an item from the end of the list, you can use the pop() method.

Lists can be accessed like traditional arrays, use the block quotes and index to get an item.

Related course: Complete Python Bootcamp: Go from zero to hero in Python

List operations

In the example below we create a list and use methods to change the list contents.
Type the program shown below and run it:

To access items, simply use the block quotes:

Study drill

Try the exercises below

After completing these continue with the next exercise.