Page 131 - Trackpad_V5_Book 8
P. 131
Program 15: To access the different elements of a list.
You will get the following output:
LIST FUNCTIONS
Let us study some of the functions we can use with lists.
The append() Function
The append() function inserts the object passed to it at the end of the list. Syntax of using append()
function is:
list_name.append(item)
Program 16: To add an element to a list using append() function.
You will get the following output:
The extend( ) Function
Using the append( ) function, we can only add one element at a time. For adding more than one
element, we use the extend( ) function. Syntax of using extend() function is:
list_name.extend(iterable value)
Functions, String and List in Python 129

