Python - Lesson 5 Python List_new
Python - Lesson 5 Python List_new
List
Form 4
PYTHON LIST AND TUPLES
The most basic data structure in Python is the sequence.
Each element of a sequence is assigned a number - its
position or index. The first index is zero, the second index
is one, and so forth.
Ordered: The items in the lists are ordered. Each item has a unique index
value. The new items will be added to the end of the list.
Heterogeneous: The list can contain different kinds of elements i.e; they can
contain elements of string, integer, Boolean, or any type.
Duplicates: The list can contain duplicates i.e., lists can have two items with
the same values.
CREATING A PYTHON LIST
Creating a list is as simple as putting different comma-separated
values between square brackets [ ]. For example:
Hint:
•Use list method index(20) to get the index number of a 20
•Next, update the item present at the location using the index number