Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Searching/Matching List like SQL
08-05-2011, 08:14 AM #1
- Join Date
- Feb 2009
- Thanked 0 Times in 0 Posts
Searching/Matching List like SQL
Hi and Good Day,
I would like to ask if I can search a list with the same concept like "select blah from bled like '%search%'". I have a table of words and I populate it to a list and loop from there instead of query every word back and forth within the table
l = ['Johns','Luke John Doe','DoeJanice'] search = 'John' if i do a: if search in l: = will result to false
08-12-2011, 04:14 PM #2
l = ['Johns','Luke John Doe','DoeJanice'] search = 'John' # Use list comprehension to generate a list of results. results = [x for x in l if search in x]
['Johns', 'Luke John Doe']I am a Man of Truth. I am a Free Human Person. I am a Peacemaker.
** Independent Multimedia Artist in Pasig **