TAGS :Viewed: 1 - Published at: a few seconds ago

[ Finding the Position of an object without index ]

I was wondering is there a method to find the position of an item in a list, in python, without using index? I've tried count and length functions but I'm not sure if my indentation is right or if if I'm writing it incorrectly.

Answer 1

If you want the position of every element in the list, I recommend you look at: How to return the position of numbers, which are same as input numbers, in a list in python?

Otherwise, if you only want the first element, why not just iterate through the length of the array using a counter and return the counter when you find what you are looking for.