[Tutor] Problem creating a search

Shashwat Anand anand.shashwat at gmail.com
Sat Jan 30 23:42:45 CET 2010

On Sun, Jan 31, 2010 at 3:47 AM, jim serson <fubarninja at hotmail.com> wrote:

>  Hi I am pretty new to python and programming in general. I am trying to
> create a search that takes a user input for a file location and user input
> to find a group of numbers or a phrase in that file count how many times it
> appears then display it.
> I have gone through a tutorials and searched I/O to find the code I need.
> Although I have not been able to make it work properly yet.
> I am able to open and read from the file the user would input but cant seem
> to make the other input retrieve the numbers or phrase from the file or have
> it count how many time it appears. If anyone can help or point me in the
> right direction I would appreciate it. Thanks for your time.
> look_in = raw_input ("Enter the search file to look in ")
> search = raw_input ("Enter your search item ")
   c = open(look_in, "r").read().count(search)
   print c
   if c:    print search, "your search was found"
   else:    print "your search was not found"
line = file.readline()
while line:
    print line
    line = file.readline()
    search == line
    if search in line:
        search = count + 1
        print count
        print search, "your search was found"
        print ("your search was not found")
Spread the cheer with Messenger for mobile. Learn

> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100131/2086a0ec/attachment-0001.htm>

More information about the Tutor mailing list