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

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -