Python Programme Keeps Looping When Not Meant To
<p>I have my code but it doesn't seem to work as expected. It needs to ask the user for input to search a file once found doesn't ask again but keeps asking. But I want it to ask the user again if the file hasn't been found. My code is as followed:</p>

<pre><code>import os, sys
from stat import *
from os.path import join

while True:
    lookfor=input("\nPlease enter file name and extension for search? \n")
    for root, dirs, files in os.walk("C:\\"):
        print("Searching", root)
        if lookfor in files:
            print("Found %s" % join(root, lookfor))
            break
        else:
            print ("File not found, please try again")
</code></pre>
