What's the fastest way to locate a list element within a list in python?

Viewed 3973

The list is similar to this:

[["12", "stuA", "stuB"], ["51", "stuC", "stuD"], ..., ["3234", "moreStuff", "andMore"]]

Now I need to locate an item (get index) only by its first value (e.g. "332"). Is there any better way to do this, apart from iterating from the first one to compare with each value?

Code:

index = 0
for item in thelist:
    if item[0] == "332":
         print index

    index = index + 1
4 Answers
Related