Recently I had to find which list something was in. I used:
def findPoint(haystack, needle): # haystack = [[1,2,3], [4,5]...,[6,7,8,9]]
for x in range(len(haystack)):
if needle in haystack[x]:
return x
raise Exception("needle: " + str(needle) + " not in haystack")
There is a haystack.index(needle) method.
The question is: “Is there a better way to do this?”
Yes, no need for range, for starters
And if you really really need the index, use
enumerate