Python Search file for a string and get the string's line number
<p>so im writing a login system with python and i would like to know if i can search a text document for the username you put in then have it output the line it was found on and search a password document. if it matches the password that you put in with the string on that line then it prints that you logged in. any and all help is appreciated.in my previous code i have it search line one and if it doesnt find the string it adds one to line then repeats till it finds it. then it checks the password file at the same line</p>

<pre><code>def checkuser(user,line):  # scan the username file for the username
    ulines = u.readlines(line)
    if user != ulines:
        line = line + 1
        checkuser(user)
    elif ulines == user:
        password(user)
</code></pre>