List Methods
As discussed before, since a list is a type of sequence, it supports all sequence operations and methods.
Lists are one of the best data structures to use. Python provides a set of list methods that makes it easy for us to store and retrieve values in order to maintain, update, and extract data. These common operations are what Python programmers perform, including slicing, sorting, appending, searching, inserting, and removing data.
The best way to understand this is to see them at work. You will learn about these handy list methods in the following exercises.
Exercise 25: Basic List Operations
In this exercise, you are going to use the basic functions of lists to check the size of a list, combining lists and duplicating lists as well. Follow these steps:
- Open a new Jupyter notebook.
- Type the following code
shopping = ["bread","milk", "eggs"]
- The length of a list is found using the
len
function.print(len(shopping...