Hi,

Assuming a list similar to this: l1=[['a',1],['b',2],['c',3]] and I want to get the index of 'c'. A one dimensional list is extremely easy; val = list.index(value). But how do I get it for a list similar to l1. I have tried ind = l1[0].index('c') and that tells me 'c' is not in list. Either my syntax is way off or I am missing the viable solution.

I am reasonably certain I could iterate over l1 until I find either the value or do not find the value. If that is the only way to go, could someone share an example of workable code to do that task reasonably well.

Thank you for your assistance.

Robert
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to