How do I find a word in a txt file using an input variable in python?
<pre><code>key=input("What is your word? ")
ans=open("file.txt","r")
for line in ans:
    for word in line.split():
        if (key) in (word):
            print("Yes")
</code></pre>

<p>The code works when I write it without the input variable but as soon as I do it comes back saying that the text I entered is not defined.</p>