0

interactive input prompt to open browsers...(will print something instead for now).

chrm = ['Google Chrome', 'Chrome']

input("type a browser..: ")
if chrm[0:1] == input():
     print("starting: " + chrm)

What my intention is for this little thing is for a person to write one of the two possible input options..."Google Chrome" or "Chrome" to get a certain response. like openfile or printing something. but I can't seem to get it right.

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
EVO
  • 29
  • 3
  • please, read [ask], review the [tour] and improve your title. – eyllanesc Aug 29 '18 at 03:14
  • 1
    Possible duplicate of [Does Python have a string 'contains' substring method?](https://stackoverflow.com/questions/3437059/does-python-have-a-string-contains-substring-method) – eyllanesc Aug 29 '18 at 03:17

1 Answers1

6

You should assign the returning value of input() to a variable, and use the in operator to test if it is one of the values in the chrm list:

chrm = ['Google Chrome', 'Chrome']

i = input("type a browser..: ")
if i in chrm:
     print("starting: " + i)
blhsing
  • 91,368
  • 6
  • 71
  • 106