DAMN. There's another rule. If the input is "like" and the line is:
I'm pretty sure. Yes, that this is like the time when I went out.
instead of printing the entire line with "..." on the sides, this must be printed:
... that this is like the time when I went out ...
No punctuation marks apparently. :(
This is what I have so far. 2 problems:
1.) I don't really know how to search folders and files in folders.
2.) When I run the program, Python displays:
Traceback (most recent call last):
File "<pyshell#88>", line 1, in <module>
main()
File "<pyshell#87>", line 16, in main
for file in open(a):
TypeError: coercing to Unicode: need string or buffer, list found
def main():
d = ""
print "This program allows you to input a keyword..."
print
print "...to be searched through files in the folder Python26 of drive C."
x = "1"
while x == "1":
print
a = os.listdir("C:\Python26")
print
b = raw_input("What would you like to search for?: ")
print
print "Keyword: ", b,
print
print
for file in open(a):
for line in file:
if b in line:
print file, ":"
print
print "\t", "...", line, "...",
print
d = d + a + ":" + "\n" + "\t" + "..." + line + "..." + "\n"
c = open(r"C:\Python26\SearchResult.txt", "w")
c.write(d)
c.close()
print
x = raw_input("Would you like to use this program again? (Typing anything other than 1 ends the program.): ")
print
print "Thank you for using this program."