fruits = ['apple', 'orange', 'banana', 'banana']
print(fruits.index('banana'))

Result

2

In cases where there are duplicate items, enumerate will be very helpful.

fruits = ['apple', 'orange', 'banana', 'banana']
print([n for n, i in enumerate(fruits) if i == 'banana'])

Result

[2, 3]

Tags: , ,