You can use a for loop iterating over the length of the list using range(len(list)) as shown below.
len(list) returns the number of indexes in the list , so that will be 3 in this case, and using the range() function will help iterate/loop over the list that many times.
Remember, in a list, the first value is at the 0th index, second value is at the 1st index and so on.
list_sample = ['apple', 'orange', 'durian', 'blackberry']
for i in range(len(list_sample)):
if list_sample[i] == 'durian':
print("Index Position of 'durian' in the list is " + str(i))
else:
pass
or You can use the enumerate() function as below:
list_sample = ['apple', 'orange', 'durian', 'blackberry'] # apple is at the
for i, value in enumerate(list_sample):
if value == 'durian':
print("Index Position of 'durian' in the list is " + str(i))
else:
pass