Page 72 - Modular v1.1 Pyhton
P. 72
Program 1: To create a list.
On running the above program, you will get the following output:
TRAVERSING A LIST
Traversing means accessing or visiting the elements of a list. Various ways to traverse a list are
indexing, negative indexing and slicing.
Indexing
The index of elements of a list starts from 0; which means if a list contains 10 elements then its
index (it is always an integer number) is from 0 to 9.
Clickipedia
In case if the user tries to access an element from a list beyond the defined range of the
list, then it will give an IndexError.
To access the list elements, the indexing operator or subscript operator [ ] is used.
Program 2: To access a list of given elements.
On running the above program, you will get the following output:
70 Touchpad MODULAR (Version 1.0)

