searching files

Chris Liechti cliechti at gmx.net
Sat May 11 11:58:01 EDT 2002


"zweistein" <zweistein at net.hr> wrote in news:abjaqq$gfu$1 at bagan.srce.hr:
> I am trying to make a simple address book program, as an excersise in my
> programming skills, and I can make everything except the search function.
> I loaded the entire file into a list, and I tried a few things, but it
> doesn't work.

generaly you can use a "for" loop.

def find(name):
    	for address in addressList:
    	    	if address.find(name) >= 0:
    	    	    	return address
    	raise Exception("not found")
 
> Anyone have any ideas, algorithms, code? Thanks!

please provide more information about your data structure and what exactly 
you want to search (names, numbers etc) and you will get more useful 
feedback from this group.

chris

-- 
Chris <cliechti at gmx.net>




More information about the Python-list mailing list