Page 84 - Modular v1.1 Pyhton
P. 84
On running the above program, you will get the following output:
UNPACKING TUPLE
Assigning individual elements of a tuple to multiple variables is called unpacking of tuples.
Program 3: To unpack a tuple.
On running the above program, you will get the following output:
TRAVERSING ELEMENTS IN A TUPLE
Traversing means accessing or visiting the elements of a tuple. Various ways to traverse a list are
indexing, negative indexing and tuple slicing.
Indexing
Indexing means searching for elements by using the index (position) of the elements for the
quick retrieval of information. The index of a tuple starts from 0. The index or subscript operator
[] is used to access the elements of a tuple. The index value must be an integer as it will result
into TypeError.
For example: If a tuple contains 5 elements, then the index value of tuple will varies from
0 to 4.
82 Touchpad MODULAR (Version 1.0)

