Table of Contents
show
Introduction to List:
A list can contain items of same type of items or different types of items
A list is an ordered and indexable sequence of data item.
Declare a list: Separate the items using commas and enclose them with square brackets [ ]
Elements in the list are ordered by their position. Each and every item has its unique index. A list can contain any number of values with different data type such as string, integer, float, real and another list
Example:
List of integer data type
list1 = [2,4,6]
List of different data type
list2=[1,2.0,"XXX"]
Empty list
list3=[]
List of List
list4=[[1,2],list1]
list4 is expanded as [[1, 2], [2, 4, 6]]
Views: 0