Lists
In this lesson, you will learn about the list object and its methods in Python.
We'll cover the following...
We'll cover the following...
Definition
A Python list is an indexable sequence of values, which may not necessarily all be of the same type. The first index is 0. You can create a list by writing a comma-separated sequence of values enclosed in brackets, [].
Here are a few examples of this:
Arbitrary size lists
In Python, you can create a list of an arbitrary size by “multiplying” it by an integer. The integer must be to the right of the * operator.
You can observe this in the following example:
Shallow copy effect in lists
Let’s assume we have a variable called x. If x is a list; and you say y = x, then y becomes another name for the same list, not a copy of x. That is, any change you make to ...