- __getitem__() is a python function which is used for find the item in the list according to their index.
Syntax-
list.__getitem__(item)
Example
list is [1,2,3,5,6,7]
list__getitem__(2) return the value at 2nd index. i.e.value is 3
program-
l=[1,2,3,"one","two"]
print("List is ",l)
item=l.__getitem__(0)
print(item)
item=l.__getitem__(1)
print(item)
item=l.__getitem__(2)
print(item)
item=l.__getitem__(3)
print(item)
item=l.__getitem__(4)
print(item)
List is [1, 2, 3, 'one', 'two']
1
2
3
one
two