0

im trying to create a function that does the same thing as the built in list opperation for index with out using the built in command for it.
what i mean is i cant have a list lets say myList=[1,2,3,4,5] i then cant simply go
mylist.index(3)
any idea on how i would go about doing this, im lost on this one?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by pyTony
0

Here is advanced version, try to understand the logic and do regular loop of it if generator is too unfamiliar:

my_list=[1,2,3,4,5]
print my_list.index(3)
print next(index for index, value in enumerate(my_list) if value==3)
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.