Lists in Python
A built-in data type that stores set of values
e
It can store elements of different types (integer, float, string, etc.)
lleg
Co
marks = [87, 64, 33, 95, 76] #marks[0], marks[1]..
pna
A
student = [”Karan”, 85, “Delhi”] #student[0], student[1]..
student[0] = “Arjun” #allowed in python
len(student) #returns length
, List Slicing
Similar to String Slicing
ge
list_name[ starting_idx : ending_idx ] #ending idx is not included
olle
C
marks = [87, 64, 33, 95, 76]
pna
marks[ 1 : 4 ] is [64, 33, 95]
A
marks[ : 4 ] is same as marks[ 0 : 4]
marks[ 1 : ] is same as marks[ 1 : len(marks) ]
marks[ -3 : -1 ] is [33, 95]
A built-in data type that stores set of values
e
It can store elements of different types (integer, float, string, etc.)
lleg
Co
marks = [87, 64, 33, 95, 76] #marks[0], marks[1]..
pna
A
student = [”Karan”, 85, “Delhi”] #student[0], student[1]..
student[0] = “Arjun” #allowed in python
len(student) #returns length
, List Slicing
Similar to String Slicing
ge
list_name[ starting_idx : ending_idx ] #ending idx is not included
olle
C
marks = [87, 64, 33, 95, 76]
pna
marks[ 1 : 4 ] is [64, 33, 95]
A
marks[ : 4 ] is same as marks[ 0 : 4]
marks[ 1 : ] is same as marks[ 1 : len(marks) ]
marks[ -3 : -1 ] is [33, 95]