"Richard Querin" <rfque...@gmail.com> wrote
I have an object that contains about 3500 list items, each list
containing
various data, some strings and some floats, like so:
['D', 123.4,'This is a project description', 'type', 52.1,'title']
What is the easiest way to search this list for a given string?
Is the format constant? In other words are items 2 and 5
always numbers and therefore can be ignored?
If so it might be something as simple as:
result = []
for item in data:
for index in [0,2,3,5]:
if 'scrip' in item[index].lower():
result.append( item)
break
And you can optimise that as much as you like... :-)
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor