python - Select an array from a multidimensional array -


in following array, want select sub-array array a when id known

a=[['id123','ddf',1],['id456','ddf',1],['id789','ddf',1]] 

i know id i.e, id456, based on how can select values ['id456','ddf',1] a without using loop.

>>> = [['id123','ddf',1],['id456','ddf',1],['id789','ddf',1]] >>> next(x x in if x[0] == 'id456') ['id456', 'ddf', 1] 

i however, recommend use of dictionary instead.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

javascript - Preserving URL fragment through CAS sign-on -

asp.net mvc - Implementing normal user/pass, Twitter & Facebook auth -