Why do I get an TypeError: 'in <string>' requires string as left operand, not list error when running my program?
<p>When i run through my python code:</p>

<pre><code>import time

print("\n\n\t\tWelcome to the Automated Troubleshooting Program\n\n")
time.sleep(1)
name = input("Before we begin, what is your name?\nName: ")

time.sleep(1)
option_end = False
while option_end == False:
option = input("Would you like to quit or carry on?\nChoice: ")
option = option.lower()
if option == 'carry on':
    option_end = True

    question_end = False
    while question_end == False:
        question = input("\nWhat is wrong with your device?\nProblem: ")
        question = question.lower()
        words = question.split()
        print("")

        searchfile = open("Mobile Troubleshooter Problems.txt", "r")

        for line in searchfile:

            if words in line:
                print (line)
                question_end = True
            searchfile.close()

            if words not in line:
                print("Invalid input.\nPlease try again.\n")
                time.sleep(1)
                question_end = False
            searchfile.close()

if option == 'quit':
    print("Shutting down in: 3")
    time.sleep(1)
    print("                                   2")
    time.sleep(1)
    print("                                   1")
    time.sleep(1)
    print("\n\n\t\t\t\t...SHUTTING DOWN...")
    time.sleep(1)
    quit()
</code></pre>

<p>I get this error:</p>

<p>line 26, in 
    if words in line:
TypeError: 'in ' requires string as left operand, not list</p>

<p>(When going through the code type: your name, 'carry on', 'device screen')</p>

<p>Here is the data from the .txt notebook file:</p>

<pre><code>screen: there is no display on the device screen - Solution: send to the supplier to get the screen fixed.
screen: the device screen is cracked - Solution: send to the supplier to get the screen fixed.
speakers: there is no sound on the device - Solution: send back to the supplier to get speakers fixed.
camera: the camera is not working - Solution: send back to the supplier to get the camera fixed.
software: the phone keeps on crashing / failing - Solution: send back to the supplier to get the software fixed.
</code></pre>

<p>To start you have an indentation error on your first while loop.</p>

<p>The problem is that you are trying to check if a list is in a string (doesn't work).</p>

<p>The split in line 19 changes the variable words to a list.</p>

<p>If you want to check if any of the words in question are in the line of search file you should try</p>

<pre><code>if any(wd in line for wd in words):
</code></pre>

python