Search in python tuple list -


db = [('cat',15,22),('dog',28,30),('human',27,80)] 

now want create search 'dog' returned value db[1]. can't still figure out (i know use sth for item in db: if 'dog' in item[:] don't know how put really.

please help?

items = [i in db if 'dog' in i] items[0] if items else none # ('dog', 28, 30) 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -