Suppose i have this list: >>> a = [['cat',2],['cat',5],['cat',9],['dog',6]] >>> a [['cat', 2], ['cat', 5], ['cat', 9], ['dog', 6]]
Now, there is a nice way to obtain the value 9.
>>> z = dict(a)
>>> z
{'dog': 6, 'cat': 9}
Is there any elegant way to extract the value 2? (Value corresponding to the
first occurence of 'cat' in the 2-D list).
Thanks,
Vikram
_______________________________________________
BangPypers mailing list
[email protected]
http://mail.python.org/mailman/listinfo/bangpypers
