I'm attempting to write a simple search engine (which you might know if you read my previous question) that runs off of tags combined in a list. Currently it's just in a basic ASCII output, with things like print functions and the like.

def main():
     active = True
     done = False
     results = []
     OTags = ['Hi', 'hi', ... #Continues onward]
     OResult = ["Type 'Hello' to access this page!"]
     BTags = ['Bye', 'see ya', ...]
     BResult = ["Type 'Goodbye' to access this page!"]

     while active:
          searchPrompt = raw_input('Https://')
          if searchPrompt in Otags:
               results.append(OResult)
          if searchPrompt in BTags:
               results.append(BResult)
          done = True
          while done == True:
               print results
               done = False

Now what this should do is if the user input is in either or both of those tags, it should print the results, which contain instructions on how to access the page you may be looking for. Now besides a lot of polishing I plan on doing at a later date, this should essentially cover the entire 'search' component. However, it only accepts the OTags or the BTags seperately, if I were to type 'Hi Goodbye', it would print a blank set of brackets. I think this is because of the fact that they're if statements, but the same thing happens if I use elif statements. So I was thinking, is there a sort of ANIF statement, something that would allow both of the inputs to be picked up? Any help is appreciated.

It seems that you are trying to define a query language. What you must do is parse that query language. For example, you could allow the user to enter several search terms separated by commas. Then parsing this query means for example split the user request into a list of search terms. For example

>>> def parse(query):
...     return [x.strip() for x in query.strip().split(',')]
... 
>>> parse("Hi, Goodbye, See ya, hello")
['Hi', 'Goodbye', 'See ya', 'hello']

You would then write tests about the resulting list in order to choose proper action.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.