[Tutor] Searching through text with multiple answers

Alan Gauld alan.gauld at yahoo.co.uk
Sun Nov 17 13:05:30 EST 2019


On 17/11/2019 17:21, Alex Kleider wrote:

> Can you be more specific as to for what it is that you are searching?
> Some examples would be most helpful.

I agree, its impossible to tell what you want from the
description.

Show us a few lines of your file and the kinds of
search data you use and the expected results.


> What follows might be another way of traversing your file:

And another using a list comprehension...

def my_traverse(f_name, search_token):
    with open(f_name, 'r') as f_obj:
      return [function_yet_to_be_written(line,search_token) for line in
f_obj]

Where the function returns whatever result you are
searching for.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos



More information about the Tutor mailing list