How to get an index of list in python?
A list is a data structure, or it can be considered a container that can be used to store multiple data at once. The list will be ordered and there will be a definite count of it. The elements are indexed according to a sequence and indexing is done with 0 as the first index.
We use index() function to get an index.
l=[1, 2, 3, 4, 5, 6, 7, 8, 9, 0] i=l.index(3) print(i)
a=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'] index=a.index('e') print(index)
This is all about getting index of list.
Please login to comment
View all comments