0

I want to use a list of search terms to go through a text file to find certain strings. There are two lists with different search terms and the user has to choose which list to choose.

I tried doing it with an if statement like this:

searchterm = raw_input("Give terms: ")
if searchterm == 'f' or 'F':
    term_list = ['f', 'F']
else:
    term_list = ['HN', 'H', 'G']

However if I print term_list it always comes back as the first list. How would I do this and why doesn't this work? Is there a better way to do this without it becoming really complex?

EDIT: found the answer in a duplicate. Thanks for the help guys, really appreciate it!

  • 1
    `if searchterm in ['f', 'F']:` or `if searchterm.lower() == 'f':` or `if searchterm == 'f' or searchterm == 'F':` – Avinash Raj Oct 23 '15 at 10:43
  • 2
    You are testing for `searchterm == 'f' or 'F'` which is like `(searchterm=='f') or 'F'` which in turn is always True – Pruthvi Raj Oct 23 '15 at 10:46

0 Answers0