Python example to access List Index and Values

listA = [11, 45,27,8,43]
# Print index of '45'
print("Index of 45: ",listA.index(45))
listB = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']
# Print index of 'Wed'
print("Index of Wed: ",listB.index('Wed'))

OUTPUT:

('Index of 45: ', 1)
('Index of Wed: ', 3)

Sharing Is Caring

Leave a Comment