Page 111 - Computer - 8
P. 111
Empty Lists
A list without any elements in it is called an Empty list. An empty list can be crated in two ways:
• list1 = [ ]
• list1 = list( )
Mixed Data List
A mixed data list contains values of different data types. An example of a mixed data list is
[“A”, 5, “Python”, 10, “Hello”]
Knowledge Discovery Subject Enrichment
A list in Python can contain another list as its element. Such a list is called a Nested list. An example of a
nested list is
List1 = [10, 20, [30, 40, 50], 60]
Here, the list of numbers [30, 40, 50] is an element of list named List1 and hence, is nested within it.
Accessing a List
Similar to traversing a string, a list can be traversed and its elements accessed by using the index of its
elements.
Lab Activity 7 Experiential Learning
To create a list with mixed data values 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.
109