list = ["pen", "pencil", "sharpner", "eraser", "board"]
print(list[2]) #print third element sharpner
print(list[:3]) #print items start index to 0 and less than index 3
print(list[1:3]) #print list start from index 1 and less than index 3
print(list[-1]) #print last element
'List' is a python collection where you can assign multiple items to it and get them using its index start from 0. You can also modify the items of a list.
You can also pass the start and end index to get list of items according to the index.
0 Comments