Help with searching a list

Tony C cappy2112 at yahoo.com
Mon Nov 11 22:13:27 EST 2002


Python newbie needs help with searching a list of lists.

What is the correct way for search a list of lists ?


import os
os.system('cls')

l3 = [ ['hello',5], ['bye',2] ]
print l3
print 2 in l3

if 'bye' in l3: 
	print 'yes'
else:
	print 'no'

if 44 in l3: 
	print 'yes'
else:
	print 'no'

This is what is printed

[ ['hello',5], ['bye',2] ]
0
no
no


thanks



More information about the Python-list mailing list