Q:

I want to take a user submitted string and search for that exact string in a log file and print the line number

Currently, I am using a regular expression to search for a pattern of numbers in a log file. I also want to add another search capability, general user submitted ascii string search and print out the line number. This is what I have and trying work around (help is appreciated):
logfile = open("13.00.log", "r")

searchString = raw_input("Enter search string: ")
for line in logfile:
    search_string = searchString.findall(line)
    for word in search_string:
        print word #ideally would like to create and write to a text file 

A:

First of all, strings don't have a findall method -- I don't know where you got that. Second, why use a string method or regex at all? For a simple string search of the kind you're describing, in is sufficient, as in if search_string in line:. To get line numbers, a quick solution is the enumerate built-in function: for line_number, line in enumerate(logfile):.  

