Page 112 - Computer - 8
P. 112
List Functions
Python provides several functions to work with lists. Some of these functions are described below:
• append( ): It is used to add an element at the end of a list. Its syntax is:
<list name>.append(value)
• extend( ): It is used to add more than one element at the end of a list. Its syntax is:
<list name>.extend(list of values)
• pop( ): It is used to delete an element from a list using its index. Its syntax is:
<list name>.pop(index)
Lab Activity 8
Experiential Learning
To create a list with values accepted from the user and display the elements in the list.
1. Type the code as shown in the image in the Python Editor.
2. Press the F5 key to execute the code. Sample output of the program is given below.
Lab Activity 9 Experiential Learning
To add elements of one list to elements of another list.
1. Type the code as shown in the image in the Python Editor.
110