Collection In Python Part -2
For Professionals and Freshers |
list:
If you want to represent group of object as a single entity where duplication's are allowed and insertion order also preserved then we should go for list.
list : [] = Square bracket indicates list.
Example : l=[]
type(l)
output:list
l.append (12)
l.append(13)
l.append(15)
l.append(20)
print(l)
output: 12,13,15,20
l.append('govind')
output: 12,13,15,20,govind
l.append(None)
output: 12,13,15,20, govind, None
l[-1]
output : None
l[-2]
output: govind
l[1:5]
output:3,4,5
Features : Insertion order preserved
Duplication allowed
Allowed Heterogeneous data
Growable In Nature
Values should be enclosed in Bracket []
l=[10,"govind",True,12.12]
l1=l12
output : 10 "govind" True,12.12 10 "govind" True 12.12
Comments
Post a Comment