0 votes
1 view
in Data Science by (18.3k points)

Say I have a


How do I find the position of 'durian' using while or for loops I know there's a code called list.index('durian') but I want to know the position of the specific item using for/while loops

1 Answer

0 votes
by (36.8k points)

You could use enumerate(...):

lst = ['apple', 'orange', 'durian', 'blackberry']

for idx, value in enumerate(lst):

    if value == "durian":


Do check out Data Science with Python course which helps you understand from scratch.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !