Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determined if a 2 dimensional list contain a value?

I have a list like following

mylist = [('value1', 'value2', 'value3'), ('secval1', 'secval2', 'secval3')]

how do I see if the list contains 'value2'?

like image 251
Tommyka Avatar asked Oct 09 '12 19:10

Tommyka


1 Answers

Use any():

any('value2' in sublist for sublist in mylist)
like image 59
Andrew Clark Avatar answered Oct 13 '22 00:10

Andrew Clark