[Tutor] Shashwat Anand you helped with search
jim serson
fubarninja at hotmail.com
Tue Feb 2 17:47:42 CET 2010
I am trying to have the search return several numbers or words in a single sentences now. I don't know if I am using the wrong format I am trying to use the split method because I thought I could return several parts of a sentence with it.
For example if it had 1 2 3 4 5 I thought I could search and return 1 3 5 or if it had “to set the function” I could return
“set function” from that line, but I can’t get it working properly.
I have tried several different approaches with split. I have tried to split it at the raw_input() line, at the if statement, putting it in a loop and declaring it separately. I have looked up, in the python library to make sure I am entering it properly. It will ether run trough and not work like I expect or it will come up with an error.
I think I am using the right method in the wrong way. If you could tell me if I am trying the correct method or give me a push in the right direction that would be grate thanks.
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.split()
if c: print search, ",", c,"Of your search was found"
else: print "Your search was not found"
_________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100202/dbb568a0/attachment.htm>
More information about the Tutor
mailing list