[Tutor] Search function
Pijus Virketis
virketis@fas.harvard.edu
Thu, 08 Nov 2001 00:51:38 -0500
Hi Edy,
> Is there any sample code on doing search function in python ? Scenario is
>user asked to input a string and it will search thru a file and print out
>the details.
Here is a link (http://www.courses.fas.harvard.edu/~qr20/lectures/Mar9/) to
a class, which I took last year and which I will CA next semmester. It is
an introduction to programming, taught in Python. The notes and code
implement a few simple searches. Note that the functions assume a list of
list of the form [[name1, phone1], [name2, phone2], ...]. However, they are
easy to modify so that they accept any old list, and the string module has
great functions to put a text file into list form. This should be
straightforward to adapt.
Cheers,
Pijus
------------------------------------------------------------
PGP PUBLIC KEY: www.fas.harvard.edu/~virketis/links
My weblog: www.fas.harvard.edu/~virketis