[Tutor] Problem creating a search
jim serson
fubarninja at hotmail.com
Sat Jan 30 23:17:50 CET 2010
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 ")
count = 0
file = open(look_in, "r")
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"
else:
print ("your search was not found")
file.close()
_________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100130/81881237/attachment.htm>
More information about the Tutor
mailing list