#I'm begginer for python. I want a program which accept search phrase as raw_input and print search phrase with which document it exists in and line number of the document (file). for example, search phrase is found in file name at line 6. but my program displays 0 and 0 with continueos loop. 

this is my code
# VARIABLE DEFINITIONS
searchPhrase = ""
line = ""
lineNumber = 0
jargonFile = ""
characterPos = 0
readLine = ""
#PROGRAM'S MAIN LOGIC
searchPhrase = raw_input("Enter search phrase: ")

while searchPhrase != "":
    with open('doc1.txt','r') as myfile:
        for line in myfile:

            while line != "":
                if searchPhrase in line:
                    characterPos = line.find(searchPhrase)
                    print "Search phrase found in line: ", lineNumber, " at", characterPos
                    lineNumber = lineNumber + 1

give me some solution

It seems to me that you only need to remove lines 14 and 18 from the above program to get a start.

Give me some solution, of course I will. All you need do is write a sizeable cheque made payable to the Python Software Foundation. When it's been cashed I'll give you a solution. When I say sizeable I am of course referring to the numbers and words indicating ow much is to be paid, not the physical dimensions.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.