Q:

Inline User Data Input Manipulation for Query Selection | Python

I am in the process of developing a troubleshooting application in Python that will allow a user to input a query. This query would contain the brand of the device and the issue or symptom of their problem. I am in the process of writing a script which essentially dissects the query to find an appropriate solution following keywords and brands of the device.
Current Code:
    #Import Modules
    import warnings
#Define Globals
brands = ["apple", "android", "windows"]
brand = ''

def Main():
    init()
    print("--Welcome to Troubleshooting Applet--")
    print("In your query please include the brand of your device and the problem / symptom of your current issue. \n")
    query = input("Enter your query: ").lower()
    brand = set(brands).intersection(query.split())
    if brand != '':
        print(brand)
    else:
        print("Brand in existance not defined")

def init():
    #warnings.filterwarnings("ignore") #Disable while debugging

if __name__ == '__main__':
    Main()

Currently, the script will identify a brand, but I am not certain on how to check for a wide number of keywords in order to follow a solution route. I would expect the solution to follow the pattern of having selected a brand a secondary array specific for the brand which would contain a number of potential errors. Each of these errors could have a solution defined.
I would appreciate any insight,
Thanks,
Sam

A:

Run this I hope this gives you some ideas. You need to fix your indentation for the main(): function.
#Define Globals
brands = ["apple", "android", "windows"]
brand = ''
import random
def Main():
        init()
        print("--Welcome to Troubleshooting Applet--")
        print("In your query please include the brand of your device and the problem / symptom of your current issue. \n")
        query = input("Enter your query: ").lower()
        brand = set(brands).intersection(query.split())
        keywords = ['custom security keywords collection', 'item2', 'key3']
        index = 0
        for i in range(len(query)):
            if query.__contains__(keywords[index]): # __iter__() # could use 'in' keyword here
                #switch/decide
                text = 'run decision'
                print(keywords[index])
            else:
                if len(keywords) < 3:
                    index = index + 1
                text1 = 'continue'
        # OR
        # Test keyword idea...
        tKeyword = random.choice(keywords)
        # You need a lot of work to come up with error decisions right?
        # You may need to start pulling from a Database and checking against large documents?
        # just trying to come up with something to get you going
        print ('RANDOM keyword for TESTING:' + tKeyword)
        if brand != '':
            print(brand)
        else:
            print("Brand in existance not defined")

def init():
        ftp = 0
    #warnings.filterwarnings("ignore") #Disable while debugging

if __name__ == '__main__':
    Main()
    print('ask yourself about escape sequences and encoding for the query? \+'
          ' I believe utf-8 is the default encoding for python 3')

def dbconnect():
    url = "http://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-python"
    url1 = "https://docs.python.org/3/reference/datamodel.html#object.__contains__"
    url2 = "مرحبا I think python is very unicode friendly.."

