List and Tuple 2
List:
List are ordered sequence. List represented by square bracket '[ ]'. List contain string , float and int.
L = ['Lunda' , 'Sundar' , 5, 99, 22.5]
the index represented using number inside bracket
L[2] => 5
Slicing list:
List and tuple are similar.
L[2:4] : [5,99]We can extend the list by writing "variable_name.extend " command.
L.extend(['variable' ,52])
L = ['Lunda' , 'Sundar' , 5, 99, 22.5,'variable' ,52]
You can add new list inside new list.
L.append()
Spliting the list by using command 'split'
"A,B,H,D".split(",")
the result will be
["A","B","H","D"]
Post a Comment