Python Forum
Combine Or and And in If Statement
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Combine Or and And in If Statement
#1
I am trying to write some code to return True if either AH, MH or GL are in mStrip. I want to apply a condition to GL (but not AH or MH) so that it is True only if ML is not in mStrip.

Is the code below correct? Is there a better way of writing it? I want to add additional And/Or conditions in the future and I can see it getting confusing very quickly.

if 'AH' in mStrip or 'MH' in mStrip or 'GL' in mStrip and not 'ML' in mStrip:
Reply


Messages In This Thread
Combine Or and And in If Statement - by JamesA - Jul-22-2021, 10:18 AM
RE: Combine Or and And in If Statement - by JamesA - Jul-24-2021, 12:26 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020