-1

I'm a beginner in python and trying to achieve the following - need help pls...

In the below code snippet, it matches for ab but not for remaining two matches...Can anyone pls point what I'm missing.

I've a txt input which is captured in text.

for line in text:
  parse = re.split('\s+', line)
  print(parse)

   if ("ab" or "yx" or "12") in line:
      print("success")
      continue
     else:
      print("failure")

The above code matches just "ab", it doesn't work for other matches like "yx" and "12". Don't know what I'm missing.

Thanks

Andy K
  • 4,944
  • 10
  • 53
  • 82
sks
  • 11
  • 3

1 Answers1

-1

I think you mean:

if "ab" in line or "yx" in line or "12" in line:
René Pijl
  • 4,310
  • 1
  • 19
  • 25
  • This is a duplicate of https://stackoverflow.com/questions/15112125/how-do-i-test-multiple-variables-against-a-value – cs95 Nov 10 '17 at 11:23